In JavaScript, data types are essential for defining the kind of data that can be stored and manipulated within a program. JavaScript supports several data types, each serving different purposes. The primary data types in JavaScript include:
Here’s a simple example demonstrating various data types in JavaScript:
// Example of different data types in JavaScript
let name = "John Doe"; // String
let age = 25; // Number
let isEmployed = true; // Boolean
let address = { // Object
street: "123 Main St",
city: "Anytown"
};
let hobbies = ["reading", "traveling", "swimming"]; // Array
let notDefined; // Undefined
let emptyValue = null; // Null
console.log(name); // Output: John Doe
console.log(age); // Output: 25
console.log(isEmployed); // Output: true
console.log(address); // Output: { street: '123 Main St', city: 'Anytown' }
console.log(hobbies); // Output: [ 'reading', 'traveling', 'swimming' ]
console.log(notDefined); // Output: undefined
console.log(emptyValue); // Output: null
How do I avoid rehashing overhead with std::set in multithreaded code?
How do I find elements with custom comparators with std::set for embedded targets?
How do I erase elements while iterating with std::set for embedded targets?
How do I provide stable iteration order with std::unordered_map for large datasets?
How do I reserve capacity ahead of time with std::unordered_map for large datasets?
How do I erase elements while iterating with std::unordered_map in multithreaded code?
How do I provide stable iteration order with std::map for embedded targets?
How do I provide stable iteration order with std::map in multithreaded code?
How do I avoid rehashing overhead with std::map in performance-sensitive code?
How do I merge two containers efficiently with std::map for embedded targets?