JS使用?? 代替 ||

	let a =null;

	let b = a??[];
	console.log(b);
	//结果 打印[]  用??代替||,用于判断运算符左侧的值为null或undefined时,才返回右侧的值

  

posted @ 2022-12-14 14:08  热爱前端的5号机器  阅读(60)  评论(0编辑  收藏  举报