JavaScript has eight fundamental data types, which can be categorized into primitive and non-primitive (reference) types.๐๐
๐นPrimitive Data Types (Immutable)
1. Number โ Represents numeric values (integers and floating-point numbers).
let num = 42;
let price = 99.99;
---------------------------------------
2. BigInt โ Used for very large integers beyond Number.MAX_SAFE_INTEGER
let bigNum = 9007199254740991n;
---------------------------------------
3. String โ Represents text data
let name = "John Doe";
---------------------------------------
4. Boolean โ Represents true or false
let isLoggedIn = true;
---------------------------------------
5. Undefined โ A variable that has been declared but not assigned a value.
let x;
console.log(x); // undefined
---------------------------------------
6. Null โ Represents an intentional absence of value.
let emptyValue = null;
---------------------------------------
7. Symbol โ Represents a unique and immutable identifier (used for object properties).
let sym = Symbol("unique");
---------------------------------------
๐นNon-Primitive Data Type (Mutable, Reference Type)
8. Object โ A collection of key-value pairs (arrays, functions, and other objects fall under this).
let person = { name: "Alice", age: 25 };
let arr = [1, 2, 3];
let func = function () { console.log("Hello"); };
---------------------------------------
Special Cases
Arrays ([]) โ Special type of object for ordered lists.
Functions (function) โ Objects with executable code.
Date, RegExp, Map, Set, WeakMap, WeakSet โ Specialized objects.
#JavaScript #LearnJavaScript #JavaScriptTutorial #JSDataTypes #JSBasics #WebDevelopment #CodingTips #FrontendDevelopment #react #FullStackDeveloper #coder #coding #react
#ProgrammingForBeginners #CodeNewbie #100DaysOfCode #TechEducation #tips #SoftwareEngineering #CodingLife #javascript