When should I use double or single quotes in JavaScript?

前端 未结 30 3363
攒了一身酷
攒了一身酷 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:17

    Single Quotes

    I wish double quotes were the standard, because they make a little bit more sense, but I keep using single quotes because they dominate the scene.

    Single quotes:

    • Airbnb
    • Facebook
    • Google
    • Grunt
    • Gulp.js
    • Node.js
    • npm (though not defined in the author's guide)
    • Wikimedia
    • WordPress
    • Yandex

    No preference:

    • Three.js

    Double quotes:

    • TypeScript
    • Douglas Crockford
    • D3.js (though not defined in .eslintrc)
    • jQuery

提交回复
热议问题