Skip to content

Instantly share code, notes, and snippets.

@JuarezLustosa
Created December 6, 2016 19:36
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save JuarezLustosa/292b59e3f36155906f1482e2ec9eaa7d to your computer and use it in GitHub Desktop.
Save JuarezLustosa/292b59e3f36155906f1482e2ec9eaa7d to your computer and use it in GitHub Desktop.
Javascript Desempenho entre typeof e direct
var loops = 1e8,
foo;
console.time('typeof');
while(loops--) {
if( typeof foo !== 'undefined' ) {}
}
console.timeEnd('typeof');
loops = 1e8;
console.time('direct');
while(loops--) {
if( foo !== undefined) {}
}
console.timeEnd('direct');
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment