Datatypes in JavaScript
The ECMAScript standard defines the following data types which are:
1. Boolean
2. null
3. undefined
4. Number
5. String
6. Object
2. null
3. undefined
4. Number
5. String
6. Object
Note: BigInt is also a numeric data type which represents Integer in precision format.
- Symbol is another datatype defined in JavaScript
1. Boolean:
It can have only two values true or false.
It can have only two values true or false.
Example: let isInterested = true
2. null:
A null value represents a reference that points to a nonexistent or invalid object or address.
A null value represents a reference that points to a nonexistent or invalid object or address.
Note: typeof null will return "object", however it is a bug in JavaScript
3. undefined:
A property whose value is undefined.
A property whose value is undefined.
Example:
let a;
console.log(a) //output: undefined
console.log(a) //output: undefined
4. Number: represents Integer or Floating value. For example 3 or 3.14
5. String:
A string is a sequence of characters which represents a text value. It can be declared using either single quotes or double quotes.
A string is a sequence of characters which represents a text value. It can be declared using either single quotes or double quotes.
Example:
let a='hello'
let b ="world"
let b ="world"
6. Object:
It is a collection of properties or key/value pairs.
It is a collection of properties or key/value pairs.
Example:
const person ={id:1, name:"A"}
Comments
Post a Comment