Javascript
/
Fundamentals
- 1 Fundamentals 11
-
Hello World
-
Code structure
-
Use strict
-
Variables
-
Data types
-
Type conversions
-
Maths
-
Comparitions
-
Conditional
-
Loops
-
Functions
- 2 Testing 2
-
Mocha
-
Nested describe
- 3 Objects 4
-
Basics
-
Reference
-
Methods
-
Constructor
- 4 Types 5
-
Primitives
-
Numbers
-
Strings
-
Arrays
-
Json
- 5 Classes 3
-
Constructor
-
Binding
-
Inheritance
/
Use strict
➟
➟
Last update: 17-01-2022
Strict
To keep the old code working, modern modifications are off by default.
/**
* When 'use script' it is located at the top of a script,
* the whole script works the “modern” way
* starting with ECMAScript 5
*
* To keep the old code working,
* modern modifications are off by default.
*/
"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, 'use strict' ...
* is enabled by default
*/
class MyClass {
constructor() {
a = 1;
}
}
let obj = new MyClass();
// ReferenceError: a is not defined
// Even if 'use strict' was not declared
➥ Questions github Fundamentals