小技巧:
temp1 = document.getElementById('id1');
temp2 = document.getElementById('id2');
which = temp1 || temp2;
如果temp1元素存在,则which指向temp1,否则which指向temp2。
Javascript中每个对象都有一个constructor属性
JavaScript中对象和数组的学习:
以下摘自javacript权威指南
objects and arrays are two fundamental datatypes in JavaScript. They are also two of the most important. Objects and arrays differ from primitive datatypes such as strings and numbers: instead of representing a single value, they are instead collections of values. An object is a collection of named values, and an array is a specialized kind of object that behaves as an ordered collection of numbered values.
(大意)对象和数组是两种基础的数据类型,同时也是比较重要的两种。它们不同与基本的像字符串或数值型数据类型。它们是值的集合。对象是属性的集合,而数组是一种有序集。
You've seen the . operator used to access the properties of an object. It is also possible to use the [] operator, which is more commonly used with arrays, to access these properties. Thus, the following two JavaScript expressions have the same value:
object.propertyobject["property"]可以简单知道,对于对象的属性有两种方式:一种是通过.,一种是类似于数组的方式访问。可以看出,使用第二种方式跟数组完全没有关系。