Single quotes in JavaScript object literal

前端 未结 4 2156
渐次进展
渐次进展 2020-12-21 05:16

I\'m looking at the Google Maps API tutorial, and I see this:



        
4条回答
  •  借酒劲吻你
    2020-12-21 06:04

    It's a good practice to wrap keys in quotes, even though not strictly required, in order to avoid the possibility of conflicts with JavaScript reserved words.

    Imagine if you had class instead of modules - class happens to be a reserved word in JavaScript, even though it is not actually used in the current specification.

提交回复
热议问题