Caching, long booleans (v2)

Revision 2 of this benchmark created on


Description

jQuery.os.windows = (platform.indexOf("win") != -1) ? true : false; jQuery.os.mac = (platform.indexOf("mac") != -1) ? true : false; jQuery.os.linux = (platform.indexOf("linux") != -1) ? true : false;

Preparation HTML

<script src="//ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js"></script>
<script>
  jQuery.os = {};
  var platform = navigator.platform.toLowerCase();
</script>

Test runner

Ready to run.

Testing in
TestOps/sec
No caching, long booleans
jQuery.os.windows = (navigator.platform.toLowerCase().indexOf("win") != -1) ? true : false;
jQuery.os.mac = (navigator.platform.toLowerCase().indexOf("mac") != -1) ? true : false;
jQuery.os.linux = (navigator.platform.toLowerCase().indexOf("linux") != -1) ? true : false;
ready
No caching, short booleans
jQuery.os.windows = (navigator.platform.toLowerCase().indexOf("win") != -1);
jQuery.os.mac = (navigator.platform.toLowerCase().indexOf("mac") != -1);
jQuery.os.linux = (navigator.platform.toLowerCase().indexOf("linux") != -1);
ready
Caching, short booleans
jQuery.os.windows = (platform.indexOf("win") != -1);
jQuery.os.mac = (platform.indexOf("mac") != -1);
jQuery.os.linux = (platform.indexOf("linux") != -1);
ready

Revisions

You can edit these tests or add more tests to this page by appending /edit to the URL.