Skip to main content

JavaScript Data Types

JavaScript Fundamentals: JavaScript Data Types

In JavaScript, how many data types are there?

View Answer:
Interview Response: Number, String, Boolean, BigInt, Null, Undefined, Object, and Symbol are JavaScript's eight fundamental data types. Except for the Object data type, all are basic data types. We call all other classes "primitive" since their values can only contain one item (a string or a number). On the other hand, we use objects to store data sets and more sophisticated things.

What operator do you use to find the type of a specific value or argument?

View Answer:
Interview Response: The typeof operator.

Technical Response: The typeof operator returns the type of the value or argument.

JavaScript supports two forms of syntax:

  1. As an operator: typeof x.
  2. As a function: typeof(x).

What type of numbers does the number type represent?

View Answer:
Interview Response: The number type represents both integers and floating-point numbers.

What is the limitation of the number type?

View Answer:
Interview Response: A number cannot represent integers larger than (253-1) or less than -(253-1) for negatives.

Technical Response: The “number” type cannot represent integer values greater than (253-1) (that’s 9007199254740991) or less than -(253-1) for negatives. It is a technical limitation caused by their internal representation, and anything beyond these values is considered a BigInt.

How should you create BigInt in JavaScript?

View Answer:
Interview Response: A BigInt value is created by appending n to the end of an integer or using the BigInt object constructor.

What are the three types of quotes available to create a string representation of a value?

View Answer:
Interview Response: Double, single, and backticks.

Technical Response: In JavaScript, there are three types of quotes used to represent a string double, single, and backtick quotes.


  1. Double quotes: "Hello".
  2. Single quotes: 'Hello'.
  3. Back-ticks: `Hello`.

What is the difference between double, single, and backtick quotes?

View Answer:
Interview Response: Backticks allow us to embed variables and expressions into a string by wrapping them in ${…}. There is no notable difference between single and double quotes.

Technical Response: Simple quotations are double and single quotes, and in JavaScript, there is almost no distinction between them. Backticks are quotations with "enhanced functionality." They allow us to embed variables and expressions inside a string, for example, by surrounding them with ${…}.

Code Example:

let name = 'John';

// embed a variable

alert(`Hello, ${name}!`); // Hello, John!
// embed an expression

alert(`the result is ${1 + 2}`); // the result is 3

Please note that we can only implement this with backticks in JavaScript. Other quotes (single and double) do not have this embedding functionality! We should make every effort to understand backticks and template literals.

What two values does the Boolean logical type have?

View Answer:
Interview Response: true and false

Technical Response: We often use this type of logical data type to store yes/no values: true means “yes, correct”, and false means “no, incorrect”. Boolean Logical data types often get used for comparisons or, more specifically, for greater or less than values in JavaScript.

Code Example:

let nameFieldChecked = true; // yes, name field is checked
let ageFieldChecked = false; // no, age field is not checked

// Greater or Less Than:
let isGreater = 4 > 1;

alert(isGreater); // true (the comparison result is "yes")

What does the NULL data type represent in JavaScript?

View Answer:
Interview Response: nothingness or empty, but not equal undefined

Technical Response: It is a unique value that represents “nothing”, “empty” or “value unknown”. It is not a representation of a value that has not to be defined, non-existing, or a null pointer like other programming languages.

What does the undefined data type represent in JavaScript?

View Answer:
Interview Response: Undefined means a value is not defined or assigned to a variable.

Technical Response: In JavaScript, undefined means a value is not defined or assigned. If a variable is declared but not assigned, its value is undefined.

Code Example:

let age;

alert(age); // shows "undefined"

// Technically, it is possible to explicitly assign undefined to a variable, but it is not recommended.

let age = 100;

// change the value to undefined

age = undefined;

alert(age); // "undefined"

What is the difference between typeof x and typeof(x) with parentheses?

View Answer:
Interview Response: typeof x acts as an operator, and typeof(x) is a function, but they work with parentheses or without them. The result is the same.

What does the typeof operator return?

View Answer:
Interview Response: The typeof operator returns a string with the name of the type, like "number" if it is a number or “function” if it’s a function.