Undefined

This means that a variable has been declared but has not been assigned a value, or it has been explicitly set to the value `undefined`.

Example: Below is an example.

Javascript
let x;
console.log(x); // Outputs: undefined

Output:

undefined output

Primitive and Non-primitive data-types in JavaScript

In JavaScript, variables hold values, and each value possesses a data type that indicates the nature of the stored information. Broadly, JavaScript classifies data types into two categories: Primitive data types and Non-primitive data types. These distinctions are essential for understanding how data is handled and manipulated within the language. Let us discuss it one by one.

Similar Reads

1. Primitive data types:

The predefined data types provided by JavaScript language are known as primitive data types. Primitive data types are also known as in-built data types....

Number

Number data type in javaScript can be used to hold decimal values as well as values without decimals....

String

The string data type in JavaScript represents a sequence of characters that are surrounded by single or double quotes....

Undefined

This means that a variable has been declared but has not been assigned a value, or it has been explicitly set to the value `undefined`....

Boolean

The boolean data type can accept only two values i.e. true and false....

Null

This data type can hold only one possible value that is null....

BigInt

BigInt data type can represent numbers greater than 253-1 which helps to perform operations on large numbers. The number is specified by writing ‘n’ at the end of the value...

Symbol

Symbol data type is used to create objects which will always be unique. these objects can be created using Symbol constructor....

Non-primitive data types:

The data types that are derived from primitive data types of the JavaScript language are known as non-primitive data types. It is also known as derived data types or reference data types....

Object

An object in Javascript is an entity having properties and methods. Everything is an object in javascript....

Array

With the help of an array, we can store more than one element under a single name....

Difference between Primitive vs Non-Primitive

PrimitiveNon-PrimitivePrimitive Data types are predefined. Non-Primitive data types are created by the programmerPrimitive Data types will have certain values.Non-Primitive data types can be NULL.Size depends on the type of data structure.Size is not fixedExamples are numbers and strings.Examples are Array and Linked List.It can start with a lowercase.It can start with uppercase....