How do I check for data types

In JavaScript, checking for data types can be done using the `typeof` operator or the `instanceof` operator. The `typeof` operator is used for primitives, while `instanceof` can be used for objects.

Here are some examples:

// Using typeof console.log(typeof "Hello, World!"); // string console.log(typeof 42); // number console.log(typeof true); // boolean console.log(typeof undefined); // undefined console.log(typeof null); // object (this is a known quirk in JavaScript) console.log(typeof Symbol("foo")); // symbol console.log(typeof BigInt(123)); // bigint // Using instanceof console.log([] instanceof Array); // true console.log({} instanceof Object); // true console.log(new Date() instanceof Date); // true

keywords: JavaScript typeof instanceof data types primitive types objects