mirror of
https://github.com/freeCodeCamp/freeCodeCamp.git
synced 2026-05-28 18:26:54 +00:00
feat(curriculum): Update JS data types lesson (#63168)
This commit is contained in:
+6
-11
@@ -21,11 +21,11 @@ The next data type is a `String`.
|
||||
|
||||
A `String` is a sequence of characters, or text, enclosed in quotes. Here are two examples:
|
||||
|
||||
```js
|
||||
```md
|
||||
"Hello, world"
|
||||
```
|
||||
|
||||
```js
|
||||
```md
|
||||
'JavaScript'
|
||||
```
|
||||
|
||||
@@ -58,24 +58,19 @@ The last two data types are the `Symbol` and `BigInt` data types.
|
||||
A `Symbol` is a special type of value in JavaScript that is always unique and cannot be changed. It's often used to create unique labels or identifiers for properties:
|
||||
|
||||
```js
|
||||
// Creating two symbols
|
||||
const symbol1 = Symbol('mySymbol');
|
||||
const symbol2 = Symbol('mySymbol');
|
||||
console.log(symbol1 === symbol2); // Outputs: false
|
||||
Symbol('mySymbol');
|
||||
```
|
||||
|
||||
In this example, we create two symbols with the same description, but they are unique.
|
||||
|
||||
`BigInt` is used for very large numbers that exceed the limit of the `Number` type:
|
||||
|
||||
```js
|
||||
const bigNumber = 1234567890123456789012345678901234567890n;
|
||||
console.log(bigNumber);
|
||||
// Outputs: 1234567890123456789012345678901234567890n
|
||||
1234567890123456789012345678901234567890n;
|
||||
```
|
||||
|
||||
In this example, we create a `BigInt` by adding `n` at the end of a very large number.
|
||||
|
||||
`Symbol` and `BigInt` are two types that are less commonly used, but they are still important to know about.
|
||||
|
||||
Understanding these data types helps you handle and work with various kinds of data in your programs, as each type has its own characteristics and behaviors.
|
||||
|
||||
# --questions--
|
||||
|
||||
Reference in New Issue
Block a user