

- 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
How to secure my JavaScript using "Strict mode"?
The “use strict” is a directive, which is a literal expression. It introduced in JavaScript 1.8.5. As the name suggests, “use strict” indicates that the code is to be executed in strict mode.
Let us declare strict mode. To declare, add the keyword “use strict” in the beginning. For global scope, declare it at the beginning of the script.
Example
<!DOCTYPE html> <html> <body> <p>An error would come, since you have used a variable, but forgot to declare it</p> <p>Press F8 to see the error.</p> <script> "use strict"; a = 1; </script> </body> </html>
Output
An error would come, since you have used a variable, but forgot to declare it Press F8 to see the error.
- Related Questions & Answers
- What is the difference between "strict" and "non-strict" modes of JavaScript?
- Why do we use "use strict" in JavaScript?
- In JavaScript Why do we use "use strict"?
- Should I include language="javascript" in my SCRIPT tags?
- How to create a "Coming Soon" page using JavaScript?
- How to enable a strict mode in javascript?
- How "getElementByID" works in JavaScript?
- JavaScript: How to map array values without using "map" method?
- What is Strict mode in JavaScript?
- How to print "Hello World!" using Python?
- "extends" keyword in JavaScript?
- Explain JavaScript "this" keyword?
- How to write "Hello, World!" program in JavaScript?
- How to use the "in" operator in JavaScript?
- Kotlin – Property initialization using "by lazy" vs. "lateinit"
Advertisements