首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 网站开发 > JavaScript >

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

2012-10-08 
js----有点像----c#中”类“,的一个例子类似于c#中的类---js没有类。script typetext/javascript languag

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>       

热点排行