2. JavaScript DataTypes
2. JavaScript DataTypes
Data Types
Contents
1. Overview
2. String
3. Number
4. BigInt
5. Boolean
6. null
7. Object
2
1. Overview
3
1. Overview
JavaScript is also a weakly typed language, which means it allows implicit type
conversion when an operation involves mismatched types, instead of throwing
errors.
const foo = 42; // foo is a number
const result = foo + "1"; // JavaScript coerces foo to a
string, so it can be concatenated with the other operand
console.log(result); // 421
Primitive Value
• Data types describe the different types or kinds of data that will be storing
in variables.
• All data types except Object are primitive data types, whereas Object is non-
primitive.
• Example:
const x = 5
const y = “Hello”
5 is an integer data.
"Hello" is a string data.
• Example:
// data is of undefined type
let data;
// data is of integer type
data = 5;
// data is of string type
data = "JavaScript Programming";
• To find the type of a variable, you can use the typeof operator.
// data is of undefined type
typeof (variableName);
7
2. String
8
3. Number
• A number type can also be +Infinity, -Infinity, and NaN (not a number).
9
4. BigInt
• In JS, Number type can only represent numbers less than (253-1) and more
than –(253-1).
10
5. Boolean
11
6. undefined
12
7. null
13
8. Object
14
Thank you
Perfect Practice, Does Perfect Thing
15