Data types in javaScript

Different Datatypes in JavaScript

In javascript every value is an object or a primitive.
A value is primitive only if its not an object.

numbers:

floating point numbers even if we dont see the decimal point
there is always floating point values. used for decimals and
integers.

eg: let varOne = 3.4545;
let varTwo =23; both are the same

A number type can also be +Infinity, -Infinity, and NaN (not a number). For example,

const number1 = 3/0;
console.log(number1); // Infinity

const number2 = -3/0;
console.log(number2); // -Infinity

// strings can't be divided by numbers
const number3 = "abc"/3;
console.log(number3); // NaN

strings:

String is used to store text. In JavaScript, strings are
surrounded by quotes:

1.Single quotes: 'Hello'
2.Double quotes: "Hello"
3.Backticks: Hello (ES6 syntax)

example:
let firstName="aishwarya";
const name = 'ram';
const name1 = "hari";
const result = The names are ${name} and ${name1};

boolean:

A JavaScript Boolean represents one of two values: true or false.

either true or false variable types.
let fullAge = true;
Boolean(10 > 9) // returns true

falsy values:

falsy values: 0,'',undefined,null,NaN

console.log(Boolean(0));

console.log(Boolean(undefined));

console.log(Boolean('Jonas'));

console.log(Boolean(()));

console.log(Boolean('')); // returns falsy values

undefined:

values taken by the variables that are not yet defined
eg: let children;

Null:

empty value variable
let food='null';

symbol:

Symbols are new primitive type introduced in ES6. Symbols are completely unique identifiers. Just like their primitive counterparts (Number, String, Boolean), they can be created using the factory function Symbol() which returns a Symbol. Every time you call the factory function, a new and unique symbol is created

BigInt:

BigInt is a built-in object in JavaScript that provides a way to represent whole numbers larger than 253-1. The largest number that JavaScript can reliably represent with the Number primitive is 253-1, which is represented by the MAX_SAFE_INTEGER constant.

14