DEV Community

Chokri K'
Chokri K'

Posted on • Originally published at khalifa.tn on

1 1

What ‘use strict’ means for in JavaScript

“strict mode”;

It’s a ECMAScript 5 feature that prevents certain actions from being taken and throws more exceptions in a JavaScript code.

The strict mode is necessary if you have a complex code to write. It introduces better error-checking, If you have a calculating algorithm.

Without this mode you can write console.log(Infinity = 0) and there is no problem with that. This will return 0 as inspected and Error “TypeError: “Infinity” is read-only”

We can use this feature into a function. For example:

// Non-strict code... (function(){ "use strict"; // Define your library strictly... })(); // Non-strict code...

But, if you activate it you’ll see a lot of problems on the console. To avoid that, try to write a clean code.

The post What ‘use strict’ means for in JavaScript appeared first on C.Khalifa.

SurveyJS custom survey software

JavaScript UI Libraries for Surveys and Forms

SurveyJS lets you build a JSON-based form management system that integrates with any backend, giving you full control over your data and no user limits. Includes support for custom question types, skip logic, integrated CCS editor, PDF export, real-time analytics & more.

Learn more

Top comments (0)

A Workflow Copilot. Tailored to You.

Pieces.app image

Our desktop app, with its intelligent copilot, streamlines coding by generating snippets, extracting code from screenshots, and accelerating problem-solving.

Read the docs