JS switch 判断依据是 == 还是 === ?

// test.js
let test = '1'
switch(test) {
	case 1:
		console.log('==')
		break;
	case '1':
		console.log('===')
		break;
}

查看结果

$ node test
===

所以,JS switch 判断依据是 ===

posted @ 2021-02-04 12:48  热心码农小吕  阅读(195)  评论(0编辑  收藏  举报