What does "use strict" mean?

What does "use strict"mean?
What does it do?

const source = [1,2,3,4,5,6,7,8,9,10];
function removeFirstTwo(list) {
  // Only change code below this line
  "use strict";
  const [a, b,...arr] = list; // Change this line
  // Only change code above this line
  return arr;
}
const arr = removeFirstTwo(source);
  **Your browser information:**

User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/90.0.4430.72 Safari/537.36 Edg/90.0.818.42.

Challenge: Use Destructuring Assignment with the Rest Parameter to Reassign Array Elements

Link to the challenge:

Strict mode is a subset of rules for JS that, as the name imply, will run the code more strictly forbidding certain things that were previously allowed in JS.

Mainly it will throw errors for stuff that previously “failed” silently.

You can read all about it from the article I linked up top. :slight_smile:

1 Like

Thanks for the quick reply.

I’ve edited your post for readability. When you enter a code block into a forum post, please precede it with a separate line of three backticks and follow it with a separate line of three backticks to make it easier to read.

You can also use the “preformatted text” tool in the editor (</>) to add backticks around text.

See this post to find the backtick on your keyboard.
Note: Backticks (`) are not single quotes (’).

“Strict mode” is a more restricted version of JavaScript, where make the code more resilient and secure in “strict mode”
some silent errors are changed to throw errors and disable some of the more confusing or undefined features in JavaScript.

For example,
Octal numeric literals are not allowed:
“use strict”;
var x = 010;

This topic was automatically closed 182 days after the last reply. New replies are no longer allowed.