-8
Data (Global Variables):

Car color.
Car x location.
Car y location.
Car x speed.

设置:

Initialize car color.
Initialize car location to starting point.
Initialize car speed.

画:

Fill background.
Display car at location with color.
Increment car's location by speed.

我从一个基本概念初始化的网站上读到了这个。

为什么我们需要初始化?

它对创建对象有什么帮助?

我们如何调整并为我们需要的对象进行正确的初始化?

4

1 回答 1

0

如果您没有初始化,您将无法访问 objects 属性(因为它是未定义的)。

var test = {
    definedProperty : "Hello"
};

alert(test.definedProperty);
alert(test.undefinedProperty);

http://jsfiddle.net/3cWzw/

于 2013-09-02T09:54:53.797 回答