Skip to content

typeof null works 60% of the time everytime #7352

Closed
@cookiengineer

Description

@cookiengineer

There's an upstream bug in v8 that was cherry-picked today and merged. The bug is as follows and also is reproducible in node itself:

Bug Description:

function foo() {
    return typeof null === 'undefined';
}

var a = 0;
var b = 0;

for (var i = 0; i < 10000; i++) {
    foo() === true ? a++ : b++;
}


var pa = ((a / (a + b)) * 100).toFixed(2);
var pb = ((b / (a + b)) * 100).toFixed(2);

console.log('true  ' + pa + '%');
console.log('false ' + pb + '%');

Outcome:

node typeof_null.js 
true  47.44%
false 52.56%

node typeof_null.js 
true  40.94%
false 59.06%

Metadata

Metadata

Assignees

No one assigned

    Labels

    v8 engineIssues and PRs related to the V8 dependency.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions