webwhite 2010-01-10
代码如下:
<script type="text/javascript"> var person = {}; person.name = "飞林沙"; person.age = 21; person.Introduce = function () { alert("My name is " + this.name + ".I'm " + this.age); }; person.Introduce(); </script>
代码如下:
<script type="text/javascript"> var person = { name: "飞林沙", age: 21, Introduce: function () { alert("My name is " + this.name + ".I'm " + this.age); } }; person.Introduce(); </script>
代码如下:
protected void Page_Load(object sender, EventArgs e) { var person = new { name = "飞林沙", age = 21 }; Response.Write("My name is " + person.name + ".I'm " + person.age); }
代码如下:
<script type="text/javascript"> var Person = function () { this.name = "飞林沙"; this.age = 21; this.Introduce = function () { alert("My name is " + this.name + ".I'm " + this.age); }; }; var person = new Person(); person.Introduce(); </script>
代码如下:
<script type="text/javascript"> var Person = function (name, age) { this.name = name; this.age = age; this.Introduce = function () { alert("My name is " + this.name + ".I'm " + this.age); }; }; var person = new Person("飞林沙", 21); person.Introduce(); </script>
代码如下:
<script type="text/javascript"> var Person = function (name, age) { this.name = name; this.age = age; this.Introduce = function () { alert("My name is " + name + ".I'm " + age); }; }; var person = new Person("飞林沙", 21); for (var p in person) { alert(p); } alert(person["name"]); </script>
代码如下:
<script type="text/javascript"> var Person = function (name, age) { var name = name; var age = age; this.GetName = function () { return name; } this.GetAge = function () { return age; } this.Introduce = function () { alert("My name is " + name + ".I'm " + age); }; }; var person = new Person("飞é林?沙3", 21); alert(person["name"]); alert(person.GetName()); </script>
class Singleton: def __new__: # 关键在于这,每一次实例化的时候,我们都只会返回这同一个instance对象 if not hasattr: cls.instance =