evaluate each operands (left to right) and returns the value of the last operand
https://www.typescriptlang.org/docs/handbook/release-notes/typescript-3-7.html#optional-chaining
Immediately stop running expression and return undefined, if encountered null or undefined
foo?.bar?.baz
array?.[0]
log?.(`log or not log`);
let x = foo ?? bar(); // equals to the much longer version below
let x = foo !== null && foo !== undefined ? foo : bar();
let s = e!.name; // Assert that e is non-null and access name
'obj' being an array, expand the expression (i.e. obj) in places where multiple arguments (function calls) or multiple elements (array literals) are expected
for (statement 1; statement 2; statement 3) {
// code block to be executed
}
var person = {fname:"John", lname:"Doe", age:25};
for (x in person) {
// iterate object keys
}
an iterator is object with:
an iterable is object implement the @@iterator method, that is:
A generator is an iterator
for/of - loops through iterable objects:
Example
for (const [key, value] of Object.entries(object1)) {
}
same as Java