Member-only story
If you’re on a free Medium plan, click here to read — Free Access
Source:- JavaScript Interview Questions
JavaScript Interview Questions For Freshers
In JavaScript, data types can be categorized into two main groups: primitive and non-primitive (also known as reference types) data types. Here’s an explanation of each:
- Primitive Data Types:
These are immutable data types that store a single value.
a. Boolean: Represents a logical value, either true or false. It is commonly used for conditions and branching in JavaScript.
let isTrue = true;
let a=5;
let isFalse = false;
console.log(isTrue); // Output: true
console.log(isFalse); // Output: false
b. Number: Represents numeric values, including integers and floating-point numbers.
let count = 10;
let price = 4.99;
console.log(count); // Output: 10
console.log(price); // Output: 4.99
undefined
c. String: Represents a sequence of characters enclosed in single or double quotes. Strings are used to represent textual data.
let message = "Hello, world!";
console.log(message); // Output…