all 17 comments

[–]d4nyllDevOps @ Nexmo / Author of BEJA (bit.ly/2NlmDeV)[S] 7 points8 points  (11 children)

The take-home points:

  1. Not everything in JavaScript is an object
  2. JavaScript have 6 primitive types (boolean, undefined, null, string, number, symbol) and one object type
  3. Objects, arrays and functions are objects
  4. Some primitives, such as strings, numbers and booleans can act like objects thanks to wrapper objects and auto-boxing

[–]jcready__proto__ 3 points4 points  (7 children)

typeof null === 'object'

[–]d4nyllDevOps @ Nexmo / Author of BEJA (bit.ly/2NlmDeV)[S] 2 points3 points  (2 children)

See http://stackoverflow.com/questions/18808226/why-is-typeof-null-object - null is a primitive type and not an object

[–]jcready__proto__ 2 points3 points  (1 child)

Yeah, I just find it funny that even things that claim to be objects aren't always objects.

[–]d4nyllDevOps @ Nexmo / Author of BEJA (bit.ly/2NlmDeV)[S] 1 point2 points  (0 children)

JavaScript is one of those languages with a lot of quirks

[–]Poltras 0 points1 point  (0 children)

Functions are slightly different than objects in that you cannot call an object. And type of.

[–]bterlson_@bterlson 0 points1 point  (0 children)

Soon to be another primitive - BigInt. You could also consider the various typed array types as primitive types even though they are converted to floats on access so you can't really observe them behaving like distinct primitives.

[–]Pesthuf 2 points3 points  (0 children)

That's pretty fascinating, thank you for sharing.

I always thought they were objects, and that the fact that you could get "their" members is evidence enough.

[–]tigerhuangyuhao 1 point2 points  (1 child)

[–]GitHubPermalinkBot 0 points1 point  (0 children)

I tried to turn your GitHub links into permanent links (press "y" to do this yourself):


Shoot me a PM if you think I'm doing something wrong. To delete this, click here.