This website uses cookies to enhance the user experience

JavaScript Interview Questions

23 Questions
JavaScript

JavaScript

Web DevelopmentFrontendBackend

Question 7

What are the different data types in JavaScript?

Answer:

JavaScript has six primitive data types: string, number, boolean, null, undefined, and symbol. Additionally, it has one complex data type: object, which includes arrays and functions. Understanding these data types is fundamental to working with JavaScript, as it affects how variables are declared, compared, and manipulated.

Here are examples of each data type:

// String
let name = 'John';

// Number
let age = 30;

// Boolean
let isMarried = true;

// Null
let car = null;

// Undefined
let address;

// Symbol
let sym = Symbol('symbol');

// Object
let person = {
    name: 'John',
    age: 30,
    isMarried: true
};

// Array (a type of object)
let colors = ['red', 'green', 'blue'];

// Function (a type of object)
function greet() {
    console.log('Hello');
}

In this example, we demonstrate the declaration of each data type, showing the versatility and range of values that can be managed within JavaScript.

Recent job openings

Greece, Athens, Attica

Remote

Full-time

Python

Python

Java

Java

+9

posted 2 days ago

Nigeria, Lagos, LA

Remote

Full-time

Java

Java

JavaScript

JavaScript

+4

posted 2 days ago

Ireland, Dublin, County Dublin

Remote

Full-time

Python

Python

TypeScript

TypeScript

+4

posted 2 days ago

Greece, Thessaloniki, Kentriki Makedonia

Remote

Full-time

JavaScript

JavaScript

TypeScript

TypeScript

+5

posted 2 days ago

Greece, Athens, Attica

Remote

SQL

SQL

posted 2 days ago