Contribute

JSFuckery

  • NotANumber (NaN) is a number

    Jan 7 · lroellin

    isNaN(NaN) // true
    typeof(NaN) // 'number'
    
  • var scopes to function

    Jan 7 · lroellin

    function foo() {
        {
            var x = 5
            let y = 6
            const z = 7
        }
        console.log(x)
        console.log(y)
        console.log(z)
    }
    foo() // 5, undefined, undefined
    
  • Automatic Global Scope

    Jan 7 · lroellin

    Variables without any qualifier (var, let/const) are automatically in the global scope (after executing the block)

    console.log(x) // x is not defined
    function foo() {
        x = 5
    }
    // x is still not defined
    foo()
    console.log(x) // 5
    

© Copyright 2018 Contributors

Powered by Hugo Theme By nodejh