https://tc39.github.io/ecma262/
Also block scoped, like let.
var obj;
obj.foo.bar;
ReferenceError
obj ? (obj.foo ? obj.foo.bar : null) : null;
obj?.foo?.bar;
Called Existential Operator in CoffeeScript
http://coffeescript.org/#existential-operator
Stage 0 to 1
https://claudepache.github.io/es-optional-chaining/
async function xd () {
// await something
}
Also supports arrow function
async () => {}
async arg => {}
But async is not keyword
var async = 1;
var async = async function async () {};
await
is keyword.
`string content`
CAN HAVE NEW LINE!!
`string
content`
supports customized tag function
function tag() {console.log(arguments);}
var foo = 'a';
tag`ha ${foo}`;
String.raw https://developer.mozilla.org/zh-TW/docs/Web/JavaScript/Reference/Global_Objects/String/raw
String.raw({raw:['xd', 'dx']}, '--');
var A = class {};
export default class {};
class B extends A {}
class B extends new A {}
A
need to be a constructor
In fact, extends followed by a LHS expression
function tag () {return function () {};}
class B extends tag`haha` {}
can be expression or literal
class C {
['1']() {}
}
class D {
2() {}
}
or keyword
class E {
class() {}
}
Thats why React need to use className
Can used to declare an object
var f = {
method() {}
}
Requires ,
to add another property
var g = {
method() {},
prop: 1
}
But not able to have ,
in class
Use ;
instead if you really want ,
class G {
class() {};
method() {}
}
- Singleline
- Multiline
and
- HTML comment
<!-- -->