<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 person1 = new Person("飞林沙", 21); var person2 = new Person("kym", 26); alert(person1.Introduce == person2.Introduce); </script>
<script type="text/javascript"> var Person = function (name, age) { this.name = name; this.age = age; }; Person.prototype.Introduce = function () { alert("My name is " + this.name + ".I'm " + this.age); } var person1 = new Person("飞林沙", 21); var person2 = new Person("kym", 26); alert(person1.Introduce == person2.Introduce); </script>