实现说明
顶层就这几处状态:depth。
使用要点
- 每一步打印都带着自己的标签:
2 ** 10:、Math.pow:、2 ** 3 ** 2:。
常见问题
运行前要先安装什么?
什么都不用额外装——运行时自带了代码所需的一切。 文件用顶层绑定保存自己的状态:depth。
核心语句
let depth = 2;
depth **= 3;
代码示例
// ** is equivalent to Math.pow
console.log('2 ** 10:', 2 ** 10);
console.log('Math.pow:', Math.pow(2, 10));
// right-associative: the right-hand exponent is evaluated first
console.log('2 ** 3 ** 2:', 2 ** 3 ** 2);
console.log('(2 ** 3) ** 2:', (2 ** 3) ** 2);
// negative and fractional exponents are both supported
console.log('2 ** -2:', 2 ** -2);
console.log('9 ** 0.5:', 9 ** 0.5);
// a result beyond the double range becomes Infinity
console.log('1e200 ** 2:', 1e200 ** 2);
// **= updates in place
let depth = 2;
depth **= 3;
console.log('depth:', depth);