Meaning of '{ }' in javascript

后端 未结 7 677
余生分开走
余生分开走 2021-02-07 17:37

What does assigning a variable to {}, mean? Is that initializing it to a function? I have code in a javascript file that says this

GLGE.Wavefront =          


        
7条回答
  •  挽巷
    挽巷 (楼主)
    2021-02-07 18:16

    Using {} creates an object. You can use the object like a hash-map or similar to how you can use arrays in PHP.

    var obj = {};
    obj['test'] = 'valuehere';
    obj.secondWay = 'secondValue';
    

    and you could access them by calling obj.test and obj['secondWay'].

提交回复
热议问题