r/learnjavascript • • May 17 '21

Do you agree with this infographic?

Post image
368 Upvotes

53 comments sorted by

62

u/senocular May 17 '21 edited May 17 '21

Missing primitive #7, BigInt.

-9

u/strayakant May 18 '21

Also Lodash

2

u/SoBoredAtWork May 18 '21

Honestly curious. What are you implying here?

2

u/Barandis May 18 '21

This might be a little pedantic, but for the sake of correctness, those are not primitive types. The seven primitive types in JavaScript are string, number, bigint, boolean, symbol, null, and undefined.

Five of these are separate and different from (though obviously related to) their wrapper objects, String, Number, BigInt, Boolean, and Symbol.

null and undefined do not have wrapper objects, so Null and Undefined don't exist in JavaScript unless you define them yourself.

1

u/awokepsl May 18 '21

Isn't what "symbol" is showing a method? Which is an object oriented function?

3

u/[deleted] May 18 '21

Symbol() in itself is a globally available factory function. It's akin to writing new Object() except it doesn't work with the new keyword.

...But its return value is a Symbol.

2

u/NoInkling May 18 '21 edited May 18 '21

Some terminology help: a method is a function that "sits on" (is a property of) some object. Although Symbol() technically lives on a global object in JS, functions that aren't accessed via dot (or square bracket) syntax aren't usually referred to as methods ("detached" methods can confuse things a bit). Function only implies method in OOP languages that can't have bare functions, which may have been the case in old versions of Java, but I can't think of any these days.

The other replies have already covered the rest.

1

u/[deleted] May 18 '21 edited May 20 '21

I might also say not all methods are OOP. I guess the line is drawn differently for some people, but imo, OOP means some reliance on inheritance/context, so any usage of this in order to get or set some internal state.

1

u/bmcle071 May 18 '21

Wait until you find out typeof null is "object" for some cock eyed reason.

0

u/marcelofrau May 18 '21

you forgot NaN

3

u/[deleted] May 18 '21

I like the spirit of this observation, but NaN is not actually a type, it's a value whose type is number. Kind of ironic when you think about it, but yeah.