You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
functionc(b,b){returnb}c(1,2)// 2 "use strict"functioncd(b,b){returnb}// 严格模式下报错// Duplicate parameter name not allowed in this context
实际上,使用 es6 函数语法的时候无论是否严格模式 ,这一条都成立。
leta=(b,b)=>b// 箭头函数不管有没严格模式都是不允许同名属性得// Uncaught SyntaxError: Duplicate parameter name not allowed in this context// 使用默认参数的时候也会报错// 不报错functionfoo(x,x,y){// ...}// 报错functionfoo(x,x,y=1){// ...}// SyntaxError: Duplicate parameter name not allowed in this context
不能使用 with 语法
我也没用过 with 语法:)
所以搜索了点资料。为什么不用 with 呢?主要是性能问题。发现在 vue2 里尤大也有用到它 with
变量必须声明之后再使用
这个好理解,下一个。
函数得参数不能有同名属性,否则报错
实际上,使用 es6 函数语法的时候无论是否严格模式 ,这一条都成立。
不能使用 with 语法
我也没用过 with 语法:)
所以搜索了点资料。为什么不用 with 呢?主要是性能问题。发现在 vue2 里尤大也有用到它 with
简单来说如果 foo 在 bar 里,就会对 bar 里的 foo 进行修改,而全局的 foo 不会发生修改。
如果 with 里的变量,在 with 定义的局部环境里没有,就会上升到高一层的环境寻找,而且会对其进行修改。
不能对只读属性进行赋值,否则报错
只读属性,包括 const,Object.defineProperty 的 writable: false。
另外,对一个使用 getter 方法读取的属性进行赋值,会报错。
不能使用前缀 0 表示八进制数,否则报错。
如果想要使用八进制数字,可以使用 es6 的新语法。
二进制 0b,0B
八进制 0o,0O => 0o100
十六进制 0x,0X(不是 es6 的)
The text was updated successfully, but these errors were encountered: