26

Dear javascript.

Kindly go fuck yourself sideways.

typeof null === "object"

Comments
  • 1
    Javascript?

    const arr = [1,2,3,4,5]

    typeof arr === object
  • 3
    Everything in js is an object. Even if typeof says otherwise.

    NaN == NaN : false
    typeof NaN : Number // NaN = "Not a Number"
  • 6
    This shit again... 🙄
  • 4
    What are you doing that requires this tho?
  • 1
    @inaba I don't need it. found out after debugging some odd behaviour.
  • 10
    Oh ffs. Not this again.

    Everything in js is an object.

    Null is a valueless object. It's where an object exists and is known to have no value.

    If you want a value that denotes emptyness without being an object, use "undefined".

    Null is supposed to be an object and there's nothing surprising about typeof returning that because that's what JavaScript, which we all know is dynamically typed, is designed to do.

    Js has plenty of faults but null and undefined work just fine if you know where to use which.
  • 2
    @hashedram amen.

    I'm also tiered of hearing the same over and over, If people would invest the time in a "why" question instead of going "haha lets make jokes about it" they would find the awnser immidiently. And that it is not JS specific in most cases.

    Also NaN is a NumberType for example sqrt(-1) Resultat in a number but It is not representable in real number. And in JS and other languages this results in NaNs.
  • 3
    I mean most things in JavaScript are objects. Even primitives have object wrappers to allow methods on the primitives. Even a function is a first class object in JS. Embrace the flexibility it gives you.
Add Comment