Checking data types
16 сентября 2023 г.
To check the type of an operand in JavaScript, you can use the typeof operator. It returns a string representing the type of the value.
The operand is placed after the typeof operator. It can be either a primitive value or an object.
JavaScript
1console.log(typeof 45); // "number"23console.log(typeof 'some string'); // "string"45console.log(typeof true); // "boolean"67console.log(typeof {one: "one", two: "two"}) // "object"89// And others