“use strict” in Javascript

Rollin_J
May 3, 2021

Safer feature set of javascript

image from unsplash

It makes function or program to work in a strict mode. It makes code faster, secure and throws any unwanted(silent) error when any unsafe event take place.

How to use:
a.strict mode for whole code, add “use script” at the very begning of the code.

b.strict mode for function, add “use script” at the very begning of the function

Why use “strict”:

  1. It restricts creation of global variable, object without declaring it.

first let’s create vaiable and object without use strict

no error

with “use strict”, and above assignment results in error

throws an error

2. Deleting function, variable and object is not allowed

3. Can not use same parameter name in function

4. Escape characters are not allowed in strict mode.

Sign up to discover human stories that deepen your understanding of the world.

Free

Distraction-free reading. No ads.

Organize your knowledge with lists and highlights.

Tell your story. Find your audience.

Membership

Read member-only stories

Support writers you read most

Earn money for your writing

Listen to audio narrations

Read offline with the Medium app

Rollin_J
Rollin_J

No responses yet

Write a response