Javascript primitive data types

Created By: chatGPT

In JavaScript, there are seven primitive data types. These data types represent single values and are not objects. Below is a brief overview of each primitive data type.
1. Undefined: A variable that has been declared but not assigned a value is of type undefined.
let x;
console.log(typeof x); // Outputs: 'undefined'
2. Null: This type represents the intentional absence of any object value. It is considered a primitive value.
let y = null;
console.log(typeof y); // Outputs: 'object'
3. Boolean: This type has only two possible values: true and false. It is used for logical operations.
let isActive = true;
let isLoggedIn = false;
console.log(typeof isActive); // Outputs: 'boolean'
4. Number: JavaScript has a single number type, which can represent both integer and floating-point numbers.
let count = 42;
let temperature = -5.1;
console.log(typeof count); // Outputs: 'number'
5. BigInt: This is a relatively new addition that allows representation of integers with arbitrary precision. It's useful for large integers.
let bigNumber = 1234567890123456789012345678901234567890n;
console.log(typeof bigNumber); // Outputs: 'bigint'
6. String: This data type is used for text. Strings can be created using single quotes, double quotes, or backticks.
let greeting = 'Hello, World!';
let name = "John";
let message = `Welcome, ${name}!`;
console.log(typeof greeting); // Outputs: 'string'
7. Symbol: Introduced in ES6, symbols are unique and immutable primitive values that can serve as identifiers for object properties.
const uniqueId = Symbol('id');
console.log(typeof uniqueId); // Outputs: 'symbol'
In summary, these primitive data types provide a way to represent basic values in JavaScript. Understanding them is crucial for effective programming.
Introduction And SetupVariablesData TypesMethodsControl FlowFunctionsOperatorsData StructuresCommentsSyntaxEvent HandlingError HandlingPrimitive Data TypesReference Data TypesConstLetVarStringNumberBooleanNullUndefinedSymbolObjectArrayTemplate LiteralsArrow FunctionsRegular FunctionsCallApplyBindAsync FunctionsPromisesCallback FunctionsIf StatementElse StatementSwitch StatementFor LoopWhile LoopDo While LoopFor EachBreak StatementContinue StatementTry CatchThrowFinallyScopeClosureThis KeywordPrototypesInheritanceConstructor FunctionsClass SyntaxStatic MethodsGettersSettersSpread OperatorRest OperatorDestructuring AssignmentMap MethodFilter MethodReduce MethodEvent ListenersDom ManipulationInnerHTMLQuerySelectorAddEventListenerPreventDefaultStopPropagationTimeoutsIntervalsJsonLocal StorageSession StorageRegexMath ObjectDate ObjectString MethodsArray MethodsObject MethodsDeep CloningShallow CloningCallback HellPromise ChainingAsync AwaitMap Vs ForEachFilter Vs ReduceNullish Coalescing OperatorOptional ChainingTypeof OperatorInstanceof OperatorStrict EqualityLoose Equality