特徴
immutable binding
LexicalBinding : BindingIdentifier
It is a Syntax Error if the BindingIdentifier if IsConstantDeclaration of the LexicalDeclaration containing this production is true.
staticに解析可能
{
const V = 20;
}
console.assert(typeof V === 'undefined');
もしもblock scopedでなければ,
if (cond) {
const V = 20;
}
// ここでVがuninitializedか, initializedかどうかは
// runtimeにしかわからない
すると, constな変数に対して, initializedかどうかのflagが必要になり, 高コスト実装になる.
It is a Syntax Error if the LeftHandSideExpression is an Identifier that statically resolves to a declarative environment record binding and the resolved binding is an immutable binding.
つまりですね,
const V = 20;
V = 30; // これがSyntaxErrorになる!
SyntaxErrorはearly error (section 16)なので, parse phaseで通知される
i is j;
k isnt l;
is / isnt
例えば, is / isntはcontextual keywordなので
var function = 20; // これはkeywordなのでだめだけど
var is = 20; // これはOK
なので, keyword増えるわけではないので, 互換性の面からは安心
これです
var DerivedArray = Array <| function DerivedArray() {
return DerivedArray.prototype <| [];
};
あんまり誰も触れたがらない魔境
継承
var Derived = Base <| function Derived() {
};
BaseがDerivedの[[Prototype]]になる (ここまでは一緒)
duplicateな変数名purge機構
!javascript function test(a) { var a = 20; }
こういうのがSyntaxErrorになる機構
If this time value is NaN, the String value is "Invalid Date"
all objects have two sequential property tables: properties with uint32 names, kept in integer order all other properties, kept in creation order
LHSがPrimaryExpression : ( Expression ) についてLeftHandSideExpressionじゃなくなるとout
(1, 2, 3) = 20;
とかがSyntaxErrorに (ES5でははReferenceError)
destructuring-assignmentはAssignmentBindingPatternについては以下の文法を認めている
({ responseText }) = res;
section 11.13 Runtime Semantics
If LeftHandSideExpression is neither an ObjectLiteral nor an ArrayLiteral then
in ES5, following script is valid
for (var i = 20 in []) {
}
for-inのVariableDeclarationはinitializerがとれた
Table of Contents | t |
---|---|
Exposé | ESC |
Full screen slides | e |
Presenter View | p |
Source Files | s |
Slide Numbers | n |
Toggle screen blanking | b |
Show/hide slide context | c |
Notes | 2 |
Help | h |