What are the primitive data types in JavaScript? Well, they are null
, undefined
, string
, number
and boolean
. Do we need more? Yes. The **symbol**
is a new primitive data type introduced in ES2015 (ES6) along with bigint
which was also introduced in this revision.
typeof null; // 'object' (it's a bug)
typeof undefined; // 'undefined'
typeof 100; // 'number'
typeof "hello"; // 'string'
typeof true; // 'boolean'
typeof Symbol(); // 'symbol'
typeof 100n; // 'bigint'
In this lesson, we are just going to talk about symbols and leave others for another day. Symbols are fascinating and not like any other data type you have seen before. For the starters, the symbol is a primitive data type, however, you can’t write it in literal form because it doesn’t have one.
#ecmascript-6 #nodejs #symbols #javascript