2025年3月20日 星期四 甲辰(龙)年 月十九 设为首页 加入收藏
rss
您当前的位置:首页 > 计算机 > 编程开发 > JavaScript

js 需要加分号的情况

时间:08-25来源:作者:点击数:29

以下是一些js必须加分号的情况:

  1. 立即执行函数:
    报错:Uncaught TypeError: xx is not a function
  • // 没有分号的话 ,Uncaught TypeError: xx is not a function
  • let x = 3;
  • (function t() {})()
  1. 数组解构
    报错:Uncaught TypeError: Cannot read properties of undefined (reading ‘xxx’)
  • // Uncaught TypeError: Cannot read properties of undefined (reading 'xxx')
  • const str = '123';
  • [1,2,3].map(item=>console.log(item*2))
方便获取更多学习、工作、生活信息请关注本站微信公众号城东书院 微信服务号城东书院 微信订阅号
推荐内容
相关内容
栏目更新
栏目热门