You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: 1-js/02-first-steps/05-types/article.md
+22-5
Original file line number
Diff line number
Diff line change
@@ -10,7 +10,7 @@ message = 123456;
10
10
11
11
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.
12
12
13
-
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
13
+
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.
14
14
15
15
## A number
16
16
@@ -182,11 +182,28 @@ The `symbol` type is used to create unique identifiers for objects. We mention i
182
182
183
183
## BigInt
184
184
185
-
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.
185
+
In JavaScript, the Number type cannot represent integer values larger than 2<sup>53</sup>-1. This limitation has forced many 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().
186
186
187
-
A BigInt is created by appending n to the end of an integer literal — 10n — or by calling the function BigInt().
187
+
```js run
188
+
consttheBiggestInt=9007199254740991n;
189
+
190
+
consthuge=BigInt(9007199254740991);
191
+
192
+
alert(typeof biggestInt); // shows "bigint"
193
+
194
+
alert(typeof huge); // shows "bigint"
195
+
```
196
+
Bigint can mostly be used like number but there are some key differences
197
+
- Most math operatioons work on it normally
198
+
- It cannot be mixed and match with number while apllying binary operations it has to be coerced into each other but be careful it can lead to some precision losses
199
+
- The / operator also works as expected with whole numbers. However, since these are BigInts and not BigDecimals, this operation will round towards 0, which is to say, it will not return any fractional digits.
200
+
201
+
To know more in detail about the java script newest addition in prmitive types please visit [MDN](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/BigInt) docs for it
188
202
189
-
Right now it sis compatible with firefix and chrome but is not supported in Safari.
203
+
204
+
```smart header="Compatability issues"
205
+
Right now it only compatible with firefox and chrome but is not supported in Safari.
206
+
```
190
207
191
208
## The typeof operator [#type-typeof]
192
209
@@ -234,7 +251,7 @@ The last three lines may need additional explanation:
234
251
235
252
## Summary
236
253
237
-
There are 7 basic data types in JavaScript.
254
+
There are 8 basic data types in JavaScript.
238
255
239
256
-`number` for numbers of any kind: integer or floating-point.
240
257
-`string` for strings. A string may have one or more characters, there's no separate single-character type.
0 commit comments