逐句學英文-對象
Objects??bd?ikt對象
An object is a collection of named values.
菲彩国际
對象是已命名的數據的集合。
These named values are usually referred to as properties of the object.
菲彩国际
這些已命名的數據通常被作為對象的屬性來引用。
For example, if an object named image has properties named width and height, you can refer to those properties like this:
菲彩国际
例如,如果一個名為image的對象有一個名為width和一個名為height的屬性,我們可以使用如下方式來引用這些屬性:
image.width
image.height
Properties of objects are, in many ways, just like JavaScript variables; they can contain any type of data, including arrays, functions, and other objects.
對象的屬性在很多方面都跟 JavaScript 的變量相似,屬性可以是任何類型的數據,包括數組、函數和其他對象。
Thus, you might see JavaScript code like this:
所以,讀者有可能會見到如下的 JavaScript代碼:
document.myform.button
This code refers to the button property of an object that is itself stored in the myform property of an object named document.
這里引用了一個對象的button屬性,而這個對象本身又存儲在對象document的myform屬性中。
When a function value is stored in a property of an object, that function is often called a method, and the property name becomes the method name.
如果一個函數值是存儲在某個對象的屬性中的,那么那個函數通常被稱為方法,屬性名也就變成了方法名。
Objects in JavaScript can serve as associative arrays; that is, they can associate arbitrary data values with arbitrary strings.
菲彩国际
JavaScript 中的對象可以作為關聯詞組使用,因為它們能夠將任意的數據值和任意的字符串關聯起來。