我在 JavaScript 中看到过两个关于对象的术语,一个是它的属性,另一个是它的属性。这些术语之间有什么区别?
Each data property (object property that store data) has not only the name-value pair, but also 3 attributes (the three attributes are set to true by default):
- Configurable Attribute: Specifies whether the property can be deleted or changed.
- Enumerable: Specifies whether the property can be returned in a for/in loop.
- Writable: Specifies whether the property can be changed.
原始上下文:http://javascriptissexy.com/javascript-objects-in-detail/
最佳答案
什么是 Javascript 中的属性和属性?
一般来说,attribute 和 property 是相同的。两者都表示质量,用技术术语来说就是键值对,所以键是属性/属性的名称,而值只不过是值。
有什么区别?
差异在于上下文而不是含义。
为什么使用两个术语?
因为即使是对象的属性也可能具有 property ,这被称为属性。
Javascript 中对象的属性是什么?
除了Object的属性之外,Object还有三个属性。 它们是原型(prototype)、类和可扩展
例如:
var SampleObject = { Name : "ObjName", id : "0"} // user created
实际对象的结构:
var SampleObject = {class :someValue, // Attribute
prototype : someValue, // Attribute
extensible : someValue, // Attribute
Name : "ObjName", // Property
id : "0" // Property
}
Javascript 中对象的属性是什么?
对象中的所有键值对都是对象的属性。
JavaScript 中对象的所有属性都有哪些属性?
对象的每个属性都具有以下 3 个属性。 可配置、可枚举和可写,这些值为 bool 值。
//Ex :
var SampleObject = { key1 :{ p1 : "v1"}} // user created
//Actual Structure :
var SampleObject = { class :someValue, // Attribute
prototype : someValue, // Attribute
extensible : someValue, // Attribute
key1 : { Configurable : true, // attribute
Enumerable : true, // attribute
Writable : true // attribute
p1 : "v1" //property
} // proeperty
}
关于javascript - Javascript 中的对象属性和对象属性有什么区别?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38017119/