// "use strict"
/** * choose to use: 'use strict' * this does not use 'use strict', there will be no error below, when 'use strict' is used, there will be an error. * * /
Copy the code
  • variable

/** * variables: An error is reported when initializing a variable without a value! * * * /
var a;
console.log(a)

Copy the code
  • object
/** * object: An object cannot have duplicate attributes, otherwise a syntax error is reported *@type {{name: string}} * /
// In strict mode
// The same name can cause a syntax error!
const obj = {
    name: 'ck'.name:'kb'
}
Copy the code
  • function
/** * function: function arguments, cannot be repeated, will not report errors, but through the name of the variable, only the second argument ** /

In strict mode, arguments cannot be repeated. If they are not in strict mode, no exception will be thrown. Only the second argument can be accessed by the parameter name.
function sum(num, num) {}

Copy the code
  • The eval method is not used. The eval method is executed in the following ways: 1. Execute internal code (so it’s expensive

/** * the eval() method */

Copy the code
  • The eval, the arguments
/** ** eval and arguments: can't declare variable names. !!!!!!!!! * /

const eval = 11;
const arguments = [1.2.3]
// This is ok in non-strict mode
Copy the code
  • This points to the
/** * Suppress this: In non-strict mode, null and undefined are converted to a global object when the apply and call methods are used. * In strict mode, this always refers to the specified object. * /

const color = 'red'
function  displayColor () {
    alert(this.color)
}

displayColor.call(null)

Copy the code
  • Other changes

/** * Other changes: With has been dropped, and base 8 data */ has been dropped

Copy the code