PROGRAMMING

  minte9
learningjourney




S R Q

Strict

To keep the old code working, modern modifications are off by default.
 
/**
 * Modern modifications are off by default, 
 * to keep the old code working
 * 
 * When 'use script' it is located at the top of a script, 
 * the whole script works the “modern” way 
 * starting with ECMAScript 5
 * .
 */
"use strict";

let a = 1;  // Correct
b = 1;      // ReferenceError: b is not defined

Classes

Modern JavaScript supports classes and modules (use strict enabled by default).
 
/**
 * In classes and modules, strict is enabled by default
 */

try {
    
    class MyClass {
        constructor() { 
            a = 1; // Look Here
        }
    }
    new MyClass();

} catch (err) {
    console.log(err.message); // a is not defined
}

Questions    
Last update: 54 days ago
Variables