ThinkChat2.0新版上线,更智能更精彩,支持会话、画图、视频、阅读、搜索等,送10W Token,即刻开启你的AI之旅 广告
# [Exponentiation operator](https://babeljs.cn/docs/plugins/transform-exponentiation-operator) 在 ES6 中可以使用 `**` 进行乘方扩展运算,可以使用 `babel-plugin-transform-exponentiation-operator` 进行语法转换。 ``` npm install --save-dev babel-plugin-transform-exponentiation-operator ``` ## .babelrc 配置 ```json { "plugins": ["transform-exponentiation-operator"] } ``` ## 使用 ### `**` in ```js let squared = 2 ** 2; // same as: 2 * 2 let cubed = 2 ** 3; // same as: 2 * 2 * 2 ``` out ```js var squared = Math.pow(2, 2); // same as: 2 * 2 var cubed = Math.pow(2, 3); // same as: 2 * 2 * 2 ``` ### `**=` in ```js let a = 2; a **= 2; // same as: a = a * a; let b = 3; b **= 3; // same as: b = b * b * b; ``` out ```js var a = 2; a = Math.pow(a, 2); // same as: a = a * a; var b = 3; b = Math.pow(b, 3) // same as: b = b * b * b; ```