JavaScript Data Types
The value types a variable can hold.
Data Types
| Type | Meaning |
|---|---|
| Number | Numeric values — integers and decimals. |
| String | Text values enclosed in quotes. |
| Boolean | True or false logical values. |
| Undefined | A variable declared but not assigned. |
| Null | The intentional absence of a value. |
| Object | Key-value pairs and complex data. |
var age = 25; // Number
var price = 9.99; // Number
var isActive = true; // Boolean
var done = false; // Boolean
var name = "Hello"; // String
var msg = ' World'; // String
var x; // Undefined (declared, not assigned)
var result = null; // Null (intentional absence of value)
var p = { name: "Ana", age: 22 }; // Object
Activity — complete the code
Complete the code correctly to mark this lesson as complete automatically.
Name the data type of each value.
var age = 25; //var name = "Hello"; //var isActive = true; //var x; //var result = null; // Nullvar p = { name: "Ana" }; //