PRIMITIVE DATA TYPES IN JAVASCRIPT
JavaScript has seven primitive data types: String, Number, BigInt, Boolean, Undefined, Null, and Symbol.Primitive types are the most basic building blocks of data in JavaScript.
They represent a single value and are immutable, meaning their internal values cannot be changed after creation.
The 7 Primitive Data Types
1. String :
Represents textual data. Strings must be enclosed in single quotes ('), double quotes ("), or backticks (`).
javascript
let name = "Alice";
let greeting = 'Hello';
2. Number :
Represents both integers and floating-point (decimal) numbers. It also includes special values like NaN (Not a Number) an Infinity.
javascript
let age = 25;
let weight = 50.1;
3. BigInt:
Large integers beyond the safe calculation limit of the standard Number type (ends with an n, e.g., 9007199254740991n).
4. Boolean:
logical entity with only two possible values: true or false.
javascript
let isCoding = true;
let isTired = false;
5.undefined
Automatically assigned to a variable that has been declared but not yet given a value.
let x console.log(x);
6. Null
Represents an intentional absence of any object value. It is used to explicitly state that a variable is empty.
javascript
let emptyValue = null;
Top comments (0)