When should I use double or single quotes in JavaScript?

前端 未结 30 4020
攒了一身酷
攒了一身酷 2020-11-21 05:02

console.log("double"); vs. console.log(\'single\');

I see more and more JavaScript libraries out there using single quotes when ha

30条回答
  •  轮回少年
    2020-11-21 05:11

    There is strictly no difference, so it is mostly a matter of taste and of what is in the string (or if the JavaScript code itself is in a string), to keep number of escapes low.

    The speed difference legend might come from PHP world, where the two quotes have different behavior.

提交回复
热议问题