Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVASCRIPT

strict mode in javascript

/*
even though x is not defined with a keyword like var, let or const, the
browser won't throw an error
*/
x = 1;

function myFunc() {
  "use strict";
  
  /*
  this will throw an error as y is being assigned a value without it 
  being declared AND "use strict" has been used for the function
  */
  y = 4;
}

/*
Basically, "use strict" is a way for programmers to avoid bad habits by using
invalid syntax which browsers accept but is still wrong
*/
 
PREVIOUS NEXT
Tagged: #strict #mode #javascript
ADD COMMENT
Topic
Name
4+9 =