我正在学习Javascript中的开关,每当我添加一个大小写时,我都不确定是使用单引号还是双引号。
switch(answer)
{
case 'hello':
console.log("Hello there!");
break;
}vs
switch(answer)
{
case "hello":
console.log("Hello there!");
break;
}请注意,在大小写中,我在第二个示例中放置了双引号而不是单引号。哪一个是对的?
发布于 2014-07-20 19:39:44
你想做什么就做什么。JavaScript中的字符串文字是用单引号或双qoutes编写的。无所谓。
case 'hello':和case "hello":一样,就像console.log('Hello there!')和console.log("Hello there!")一样
https://stackoverflow.com/questions/24854165
复制相似问题