BigInt Type added in primitive types

This commit is contained in:
ajitsinghkaler 2019-11-20 22:46:31 +05:30
parent e515f80a9f
commit c7a9080934

View file

@ -10,7 +10,7 @@ message = 123456;
Programming languages that allow such things are called "dynamically typed", meaning that there are data types, but variables are not bound to any of them. Programming languages that allow such things are called "dynamically typed", meaning that there are data types, but variables are not bound to any of them.
There are seven basic data types in JavaScript. Here, we'll cover them in general and in the next chapters we'll talk about each of them in detail. There are eight basic data types in JavaScript. Here, we'll cover them in general and in the next chapters we'll talk about each of them in detail. We will cover about bigInt later for now you can acess [MDN](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/BigInt) docs for it
## A number ## A number
@ -180,6 +180,14 @@ All other types are called "primitive" because their values can contain only a s
The `symbol` type is used to create unique identifiers for objects. We mention it here for completeness, but we'll study it after objects. The `symbol` type is used to create unique identifiers for objects. We mention it here for completeness, but we'll study it after objects.
## BigInt
In JavaScript, the Number type cannot represent integer values larger than 2<sup>53</sup>. This limitation has forcedmany of us to use inefficient workarounds. BigInt is a new data type intended to fix just that.
A BigInt is created by appending n to the end of an integer literal — 10n — or by calling the function BigInt().
Right now it sis compatible with firefix and chrome but is not supported in Safari.
## The typeof operator [#type-typeof] ## The typeof operator [#type-typeof]
The `typeof` operator returns the type of the argument. It's useful when we want to process values of different types differently or just want to do a quick check. The `typeof` operator returns the type of the argument. It's useful when we want to process values of different types differently or just want to do a quick check.
@ -235,6 +243,7 @@ There are 7 basic data types in JavaScript.
- `undefined` for unassigned values -- a standalone type that has a single value `undefined`. - `undefined` for unassigned values -- a standalone type that has a single value `undefined`.
- `object` for more complex data structures. - `object` for more complex data structures.
- `symbol` for unique identifiers. - `symbol` for unique identifiers.
- `bigint` is for displaying numbers greater than 2<sup>53</sup>-1
The `typeof` operator allows us to see which type is stored in a variable. The `typeof` operator allows us to see which type is stored in a variable.