include:
let arr1 = [1, 2, 3]
console.log(arr1.includes(2))
console.log(arr1.includes(4))
console.log(arr1.includes(2,1))
console.log(arr1.includes(2,-2))
指数运算:
console.log(Math.pow(2, 3))
console.log(2 ** 3)
console.log(Math.pow(3, 2))
console.log(3 ** 2)
函数中严格模式的变更:
// "use strict"
{
// function fun() {
// "use strict"
// //code
// }
}
{
// function fun(a, b = a) {
// //"use strict"
// //code
// }
}
{
// function fun({ a, b }) {
// "use strict"
// //code
// }
// fun({ a: 1, b: 2 })
}
{
// function fun(...a) {
// "use strict"
// }
}
//函数执行,先执行函数参数,再函数体
//在函数体中定义 "use strict",只有在函数体中才能知道参数是否应该严格模式
//但是参数却应该先于函数体的执行
//解决方案一 设定全局严格模式
//解决方案二,将函数包在一个无参数的立即执行函数内
const fun = (
function () {
"use strict"
return function (value = 100) {
return value;
}
}()
)
console.log(fun(50))