下面代码输出什么:123['toString'].length + 123
参考答案
输出 124。
拆解:
123['toString']等价(123).toString,即Number.prototype.toString,是一个函数;- 函数
.length= 形参个数;Number.prototype.toString(radix)有 1 个形参 →1; 1 + 123 = 124。
注意:toString 的 length 在规范中是 1(radix 参数);若写成 123..toString.length 结果相同。