Created
January 13, 2020 17:07
-
-
Save r3dm1ke/bcb65f699c977ca539da0bfdb2e5f7b8 to your computer and use it in GitHub Desktop.
Primitive vs complex data structures
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // string is a primitive data type | |
| const name = 'Michael'; | |
| name.toUpperCase(); | |
| // toUpperCase is not a method; it does not mutate | |
| // the original variable | |
| console.log(name); // Michael | |
| // instead, it returns a new one | |
| const NAME = name.toUpperCase(); | |
| console.log(NAME); // MICHAEL | |
| // list is a complex data type | |
| const names = ['Alice']; | |
| // push mutates the original array | |
| names.push('Bob'); | |
| console.log(names); // ['Alice', 'Bob'] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment