String
const dataTypeString = () => {
return "I am a sample text";
};
Number
const dataTypeNumber = () => {
return 5;
};
/* Special numeric values NaN (Not a Number). Infinity - Infinity, or any number of other numeric operations that
don’t yield a meaningful result.*/
const dataTypeNotANumber = () => {
return 0 / 0;
};
BigInt
/* JavaScript Numbers can only safely store integers up to 2^53 - 1
BigInt (with n) is used for working with integers larger than that limit */
// Using BigInt literal with "n" suffix (precise, preferred)
const dataTypeBigInt = () => {
return 1234567890123456789012345n;
};
// Using BigInt() constructor with a Number (may lose precision for large values)
const dataTypeBigInt = () => {
return BigInt(1234567890123456789012345);
};
Boolean
const dataTypeBoolean = (value) => {
return value === 1 ? true : false;
};
Undefined
const dataTypeUndefined = () => {
return;
};
Null
const dataTypeNull = () => {
return null;
};
Symbol