Flugelhorn reflections on JavaScript


  • area_pol

    Today, for no reason at all, I was contemplating undefined in JavaScript, and what a wonderful mess it is.

    > a = {}
    > a.b
    undefined
    > 'b' in a
    false
    

    ok

    > a.b = undefined
    > a.b
    undefined
    > 'b' in a
    true
    

    ok?

    > typeof undefined
    "undefined"
    > undefined = 1
    1
    > typeof undefined
    "undefined"
    

    ok...

    > a.b = undefined
    undefined
    > typeof a.b
    "undefined"
    > a.b == undefined
    true
    > a.b = null
    null
    > typeof a.b
    "object"
    > a.b == undefined
    true
    

    ...ok

    > a.b = {}
    {}
    > typeof a.b
    "object"
    > a.b == undefined
    false
    

    ?ok

    Since undefined is a defined property of undefined type, you can define another undefined property using this defined undefined one.

    c6e0375f-80f6-4406-9299-80fcc38f9073-image.png


Log in to reply