xuning227 发表于 2013-1-26 15:40:23

js----有点像----c#中”类“,的一个例子

类似于c#中的类---js没有类。
          <script type="text/javascript" language="javascript">      function Person(name,age) {            this.Name = name;            this.Age = age;            this.sayhello = function () {                alert("nihao,wo shi"+this.Name+",wo"+this.Age+"sui");            }      }      var p1 = new Person("xuning", 27);      p1.sayhello();      p1.gender = "男人"; //这样都可以的,毛毛哦~~动态的      alert(p1.gender);   </script>
页: [1]
查看完整版本: js----有点像----c#中”类“,的一个例子