Javascript array best practice to use [] instead of new array?

前端 未结 5 1093
醉话见心
醉话见心 2020-12-31 04:08

I read at many tutorials that the current best practices to create a new javascript array is to use

var arr = [] 

instead of



        
5条回答
  •  挽巷
    挽巷 (楼主)
    2020-12-31 04:32

    It might be because the Array object can be overwritten in JavaScript but the array literal notation cannot. See this answer for an example

提交回复
热议问题