日期:2014-05-16  浏览次数:20330 次

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>