“strikter Modus” Code-Antworten

JavaScript -strenger Modus in der Funktion

myVariable = 9;
console.log(myVariable); // 9

function hello() {

    // applicable only for this function
    'use strict';

    string = 'hello'; // throws an error
}

hello();
SAMER SAEID

strikter Modus

Strict mode makes several changes to normal JavaScript semantics:
-Eliminates some JavaScript silent errors by changing them to throw errors.
-Fixes mistakes that make it difficult for JavaScript engines to perform 
optimizations: strict mode code can sometimes be made to run faster than 
identical code that's not strict mode.
-Prohibits some syntax likely to be defined in future versions of ECMAScript.
Owlthegentleman

Schalten Sie die moderne JS ein, indem Sie Ihrem Skript strenge Verwendung hinzufügen

// Non-strict code...

(function(){
  "use strict";

  // Define your library strictly...
})();

// Non-strict code... 
Aggressive Ant

Verwenden Sie strenge JavaScript

// File: myscript.js

'use strict';
var a = 2;
....
Repulsive Raven

Verwenden Sie strenge JavaScript

function doSomething() {
    'use strict';
    ...
}
Repulsive Raven

Ähnliche Antworten wie “strikter Modus”

Fragen ähnlich wie “strikter Modus”

Weitere verwandte Antworten zu “strikter Modus” auf JavaScript

Durchsuchen Sie beliebte Code-Antworten nach Sprache

Durchsuchen Sie andere Codesprachen