Open In App

What are Primitive Data Types in JavaScript ?

Primitive data types are the built-in data types provided by all programming languages. Examples of primitive data types in JavaScript are string, number, boolean, null, symbol, and undefined. These data types can store only a single value of a particular type in the memory.

The primitive data types are explained below:



Example: The below code practically implements all the primitive data types available in JavaScript.




const str = "GeeksforGeeks";
const num = 25;
let undef;
const nulled = null;
const workForce = Symbol(200);
const obj = {
    name: "GFG",
    desc: 'A Computer Science Portal.',
    [workForce]: 200
}
console.log(typeof str, typeof num, typeof undef,
    typeof nulled, typeof workForce
);
console.log(obj[workForce]);

Output

string number undefined object symbol
200

Article Tags :