You might notice that the Default JavaScript uses the keyword: strict.  Just what does this mean?

Check out the link: http://aka.ms/yrtkz4

In JavaScript when you use strict mode the code you write is forced into a more disciplined design then JavaScript normally does.  You have to declare your variables (I like that), writing to a read-only property will throw an error or use the wicked “with” statement.

Here is a simple table that I modified from the link:http://aka.ms/u5m1xy , go to that link to see useful examples.  This one you could print out and put beside your development system, I find that useful.

Language element

Restriction

Error

Variable

Using a variable without declaring it.

 

Read-only property

Writing to a read-only property.

 

Non-extensible property

Adding a property to an object whose extensible attribute is set to false.

 

delete

Deleting a variable, a function, or an argument.

Deleting a property whose configurable attribute is set to false.

SCRIPT1045: Calling delete on expression not allowed in strict mode

Duplicating a property

Defining a property more than once in an object literal.

SCRIPT1046: Multiple definitions of a property not allowed in strict mode

Duplicating a parameter name

Using a parameter name more than once in a function.

SCRIPT1038: Duplicate formal parameter names not allowed in strict mode

Future reserved keywords

Using a future reserved keyword as a variable or function name.

SCRIPT1050: The use of a future reserved word for an identifier is invalid. The identifier name is reserved in strict mode.

Octals

Assigning an octal value to a numeric literal, or attempting to use an escape on an octal value.

SCRIPT1039: Octal numeric literals and escape characters not allowed in strict mode

this

The value of this is not converted to the global object when it is null or undefined.

 

eval as an identifier

The string "eval" cannot be used as an identifier (variable or function name, parameter name, and so on).

 

Function declared inside a statement or a block

You cannot declare a function inside a statement or a block.

SCRIPT1047: In strict mode, function declarations cannot be nested inside a statement or block. They may only appear at the top level or directly inside a function body.

Variable declared inside an eval function

If a variable is declared inside an eval function, it cannot be used outside that function.

SCRIPT1041: Invalid usage of 'eval' in strict mode

Arguments as an identifier

The string "arguments" cannot be used as an identifier (variable or function name, parameter name, and so on).

SCRIPT1042: Invalid usage of 'arguments' in strict mode

arguments inside a function

You cannot change the values of members of the local arguments object.

 

arguments.callee

Not allowed.

 

with

Not allowed.