Run details:
Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/108.0.0.0 Safari/537.36
Chrome 108
Windows
Desktop
2 years ago
Test name Executions per second
test truth 1078204800.0 Ops/sec
test undefined 12296229.0 Ops/sec
test hasOwnProperty 160367280.0 Ops/sec
test in === 1127436672.0 Ops/sec
test in ! 1126103936.0 Ops/sec
Tests:
  • test truth

    AخA
     
    var n = {};
    while(true) {
        if(!n.foo) 
            break;
    }
  • test undefined

     
    var n = {};
    while(true) {
        if(n.foo===undefined) 
            break;
    }
  • test hasOwnProperty

     
    var n = {};
    while(true) {
        if(!n.hasOwnProperty('foo')) 
            break;
    }
  • test in ===

     
    var n = {};
    while(true) {
        if('foo' in n === false) 
            break;
    }
  • test in !

     
    var n = {};
    while(true) {
        if(!('foo' in n)) 
            break;
    }