JavaScript Interview Question: What are the 8 Data Types in JavaScript?

Photo by Markus Spiske on UnsplashThere are 8 basic data types in JavaScript.NullUndefinedNumberBooleanBigIntsObjectStringSymbolHow to remember them? Learn the mnemonic: NUNBBOSS.Now that we know there are 8 data types, what exactly are these data type…


This content originally appeared on Bits and Pieces - Medium and was authored by Aman

Photo by Markus Spiske on Unsplash

There are 8 basic data types in JavaScript.

  1. Null
  2. Undefined
  3. Number
  4. Boolean
  5. BigInts
  6. Object
  7. String
  8. Symbol

How to remember them? Learn the mnemonic: NUNBBOSS.

Now that we know there are 8 data types, what exactly are these data types used for?

Of the 8 data types, 7 are primitive. And what exactly does “primitive” mean?

A primitive data type can contain only a single thing. All primitive types are immutable and we cannot set properties on them.

Objects are the only non-primitive type because they are used to store collections of data and more complex entities.

You might be thinking, “Hey but I heard that everything in JavaScript is an object! If a string is not an object, how come I can do the following:

The above logic makes the string “hi” look like an object because we are using a method on it. This is an illusion! JavaScript will create a temporary object when we want to use a method for a primitive type and then immediately discard it!

Build composable applications

Don’t build web monoliths. Use Bit to create and compose decoupled software components — in your favorite frameworks like React or Node. Build scalable and modular applications with a powerful and enjoyable dev experience.

Bring your team to Bit Cloud to host and collaborate on components together, and greatly speed up, scale, and standardize development as a team. Start with composable frontends like a Design System or Micro Frontends, or explore the composable backend. Give it a try →

Learn More


JavaScript Interview Question: What are the 8 Data Types in JavaScript? was originally published in Bits and Pieces on Medium, where people are continuing the conversation by highlighting and responding to this story.


This content originally appeared on Bits and Pieces - Medium and was authored by Aman


Print Share Comment Cite Upload Translate Updates
APA

Aman | Sciencx (2022-03-23T08:55:30+00:00) JavaScript Interview Question: What are the 8 Data Types in JavaScript?. Retrieved from https://www.scien.cx/2022/03/23/javascript-interview-question-what-are-the-8-data-types-in-javascript/

MLA
" » JavaScript Interview Question: What are the 8 Data Types in JavaScript?." Aman | Sciencx - Wednesday March 23, 2022, https://www.scien.cx/2022/03/23/javascript-interview-question-what-are-the-8-data-types-in-javascript/
HARVARD
Aman | Sciencx Wednesday March 23, 2022 » JavaScript Interview Question: What are the 8 Data Types in JavaScript?., viewed ,<https://www.scien.cx/2022/03/23/javascript-interview-question-what-are-the-8-data-types-in-javascript/>
VANCOUVER
Aman | Sciencx - » JavaScript Interview Question: What are the 8 Data Types in JavaScript?. [Internet]. [Accessed ]. Available from: https://www.scien.cx/2022/03/23/javascript-interview-question-what-are-the-8-data-types-in-javascript/
CHICAGO
" » JavaScript Interview Question: What are the 8 Data Types in JavaScript?." Aman | Sciencx - Accessed . https://www.scien.cx/2022/03/23/javascript-interview-question-what-are-the-8-data-types-in-javascript/
IEEE
" » JavaScript Interview Question: What are the 8 Data Types in JavaScript?." Aman | Sciencx [Online]. Available: https://www.scien.cx/2022/03/23/javascript-interview-question-what-are-the-8-data-types-in-javascript/. [Accessed: ]
rf:citation
» JavaScript Interview Question: What are the 8 Data Types in JavaScript? | Aman | Sciencx | https://www.scien.cx/2022/03/23/javascript-interview-question-what-are-the-8-data-types-in-javascript/ |

Please log in to upload a file.




There are no updates yet.
Click the Upload button above to add an update.

You must be logged in to translate posts. Please log in or register.