Undefined Check

JavaScript performance comparison

Test case created

Test runner

Warning! For accurate results, please disable Firebug before running the tests. (Why?)

Java applet disabled.

Testing in unknown unknown
Test Ops/sec
Check w/ RegExp
if (/^u/.test(typeof define)) {
  define = function() { };
Check w/ charAt(0)
if ((typeof define).charAt(0)==='u') {
  define = function() {};
Check w/ string indexer
// Accessing characters as numeric properties of a string is non-standard
// prior to ECMAScript 5 and doesn't work in all browsers. (eg, IE6 and IE7)
if ((typeof define)[0]==='u') {
  define = function() {};
Check w/ global object
// Because "this" equals to global object to avoid ReferenceError try to
// resolve define function as a property of top object on the scope chain
if (!this.define) {
  define = function() {};

Compare results of other browsers


You can edit these tests or add even more tests to this page by appending /edit to the URL. Here’s a list of current revisions for this page:


Comment form temporarily disabled.

Add a comment