javascript中'{}'的含义 [英] Meaning of '{ }' in javascript
问题描述
将变量分配给 {}
是什么意思?是将它初始化为函数吗?我在javascript文件中有代码,说明这个
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 = function(uid) {
GLGE.Assets.registerAsset(this,uid);
this.multimaterials = [];
this.materials = {}; // <---
this.instances = [];
this.renderCaches = [];
this.queue = [];
};
该分配与数组有何不同?它是一种数组吗?
how is that assignment different from an array? Is it a type of array?
推荐答案
将变量赋给{}是什么意思?
What does assigning a variable to {}, mean?
这是 object literal (没有自己的属性)。
It is an object literal (with no properties of its own).
是否将其初始化为a函数?
Is that initializing it to a function?
不,那将是 = function(){}
。
该分配与数组有何不同?
how is that assignment different from an array?
数组中有许多基本对象中没有的功能,例如 .length
和一组方法。
An array has a bunch of features not found in a basic object, such as .length
and a bundle of methods.
对象通常用于存储任意键/值对。数组用于有序值。
Objects are often used to store arbitrary key/value pairs. Arrays are for ordered values.
这篇关于javascript中'{}'的含义的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!