美文网首页
no LineTerminator here

no LineTerminator here

作者: HelenYin | 来源:发表于2019-11-05 11:17 被阅读0次

自动插入分号规则

  • 要有换行符,且下一个符号是不符合语法的,那么就尝试插入分号
  • 有换行符, 且语法中规定此处不能有换行符,那么就尝试插入分号
  • 源代码结束处,不能形成完成的脚本或者模块结构

no LineTerminator here

表示它所在的结构中的这一位置不能插入换行符

不写分号容易造成的错误
  • 以括号开头的语句
  • 以数组开头的语句
var a = [[]]/* 这里没有被自动插入分号 */
[3, 2, 1, 0].forEach(e => console.log(e))

相关文章

网友评论

      本文标题:no LineTerminator here

      本文链接:https://www.haomeiwen.com/subject/hyydyctx.html