eqeqeq vs eq (v2)

Revision 2 of this benchmark created on


Description

Check performance of === vs == in varying situations.

Preparation HTML

<script>
  var u = undefined,
      i = 0,
      a = "0",
      n = null,
      e = '';
</script>

Test runner

Ready to run.

Testing in
TestOps/sec
u === undefined
if (u === undefined) {
 e = '';
}
ready
u == undefined
if (u == undefined) {
 e = '';
}
ready
typeof u === 'undefined'
if (typeof u === 'undefined') {
 e = '';
}
ready
typeof u == 'undefined'
if (typeof u == 'undefined') {
 e = '';
}
ready
i === 0
if (i === 0) {
 e = '';
}
ready
i == 0
if (i == 0) {
 e = '';
}
ready
i === '0'
if (i === '0') {
 e = '';
}
ready
i == '0'
if (i == '0') {
 e = '';
}
ready
a === 0
if (a === 0) {
 e = '';
}
ready
a == 0
if (a == 0) {
 e = '';
}
ready
a === '0'
if (a === '0') {
 e = '';
}
ready
a == '0'
if (a == '0') {
 e = '';
}
ready
n === null
if (n === null) {
 e = '';
}
ready
n == null
if (n == null) {
 e = '';
}
ready
n === 0
if (n === 0) {
 e = '';
}
ready
e === ''
if (e === '') {
 e = '';
}
ready
e == ''
if (e == '') {
 e = '';
}
ready
e.length === 0
if (e.length === 0) {
 e = '';
}
ready
e.length == 0
if (e.length == 0) {
 e = '';
}
ready
e.length !== 0
if (e.length !== 0) {
 e = '';
}
ready
e.length != 0
if (e.length != 0) {
 e = '';
}
ready
e.length
if (e.length) {
 e = '';
}
ready

Revisions

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

  • Revision 1: published on
  • Revision 2: published on
  • Revision 3: published by Mike McCaughan on
  • Revision 4: published by Mike McCaughan on
  • Revision 5: published by Mike McCaughan on
  • Revision 6: published by Mike McCaughan on
  • Revision 7: published by Mike McCaughan on
  • Revision 8: published on