
JavaScript Standard Style:https://standardjs.com/readme-zhcn.html
Airbnb JavaScript Style:https://github.com/sivan/javascript-style-guide/blob/master/es5/README.md
当一行代码是以:
(
[
`
开头的时候,则在前面补上一个分号用以避免一些语法解析错误。
所以你会发现在一些第三方的代码中能看到一上来就以一个 ; 开头。“;”function say() {
console.log('hello world')
}
// TypeError: say(...) is not a function
say()
;(function () {
console.log('hello')
})()
;['苹果', '香蕉'].forEach(function (item) {
console.log(item)
})
"`" 是 EcmaScript 6 中新增的一种字符串包裹方式,叫做:模板字符串, var foo = `
大家好
hello 床前明月光
world
哈哈哈 `
console.log(foo)