This website uses cookies to enhance the user experience

JavaScript Interview Questions

23 Questions
JavaScript

JavaScript

Web DevelopmentFrontendBackend

Question 16

What is strict mode in JavaScript?

Answer:

Strict mode is a way to opt into a restricted variant of JavaScript, which catches common coding errors and unsafe actions such as defining global variables. It can be enabled by adding 'use strict'; at the beginning of a script or function. Strict mode helps in writing secure JavaScript code by eliminating silent errors, improving performance, and preventing certain actions like the use of undeclared variables.

Here is an example demonstrating strict mode:

'use strict';

// This will throw an error because x is not declared
x = 3.14;

// This will throw an error because duplicate parameter names are not allowed
function sum(a, a, c) {
    return a + a + c; // Duplicate parameter name not allowed in strict mode
}

// This will throw an error because deleting a function is not allowed
function myFunction() {}
delete myFunction;

In this example, strict mode catches errors that would otherwise be ignored in non-strict mode, such as using undeclared variables, duplicate function parameters, and deleting a function.

Recent job openings

Egypt, Giza, Ad Doqi

Remote

Full-time

Java

Java

PHP

PHP

posted 1 week ago

United Kingdom, Cambridge, England

Remote

Full-time

Python

Python

posted 1 week ago

Greece, Nea Ionia, Attica

Remote

Full-time

Swift

Swift

TypeScript

TypeScript

posted 1 week ago

Bulgaria

Remote

Full-time

SQL

SQL

React

React

posted 1 week ago
company logo
Senior Software Engineer (Java)

FINARTIX Fintech Solutions S.A.

Greece, Athens, Attica

Remote

Full-time

Java

Java

SQL

SQL

+4

posted 1 week ago