

- Trending Categories
Data Structure
Networking
RDBMS
Operating System
Java
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
What are the characteristics of JavaScript 'Strict Mode'?
Strict Mode is a feature introduced in ES5 that allows you to place a program, or a function, in a “strict” mode.
This strict context prevents certain actions from being taken and throws more exceptions (generally providing the user with more information). Some specific features of strict mode −
Variables not declared but being assigned directly will fail. An attempt to assign foo = "bar"; where ‘foo’ hasn’t been defined will fail.
You cannot use eval in strict mode
You cannot reassign arguments array inside a function
Use of with statements is not allowed
You can use your scripts in strict mode as follows −
Add the following at the top of a script to enable it for the whole script −
"use strict";
If you want to use it only within a function then add it only in that context.
function strictFunc() { "use strict"; // rest of function }
- Related Questions & Answers
- What is Strict mode in JavaScript?
- Finding the sum of two numbers without using '+', '-', '/', '*' in JavaScript
- what is the main difference between '=' and '==' operators in javascript?
- Strict Mode in ReactJS
- What is the importance of '/g' flag in JavaScript?
- What is the importance of '/i' flag in JavaScript?
- What is the 'new' keyword in JavaScript?
- What are the components of 'user interface' of Windows Operating System?
- What is the relation between 'null' and '0' in JavaScript?
- What is the importance of 'for await...of' statement in JavaScript?
- How to enable a strict mode in javascript?
- What is Strict Mode in JavaScript and How to Enable It?
- What is the difference between 'throw new Error' and 'throw someObject' in javascript?
- What is 'delete' Operator in JavaScript?
- What is 'new' Operator in JavaScript?