When should I use double or single quotes in JavaScript?

前端 未结 30 3350
攒了一身酷
攒了一身酷 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 isn't any difference between single and double quotes in JavaScript.

    The specification is important:

    Maybe there are performance differences, but they are absolutely minimum and can change any day according to browsers' implementation. Further discussion is futile unless your JavaScript application is hundreds of thousands lines long.

    It's like a benchmark if

    a=b;
    

    is faster than

    a = b;
    

    (extra spaces)

    today, in a particular browser and platform, etc.

提交回复
热议问题