javascript对象

来源:互联网 发布:淘宝等级2颗钻 编辑:程序博客网 时间:2024/04/30 03:27

function person(name, age, birthday,id) {
            this.name = name; //公有属性
            this.age = age;//公有属性
            this.birthday = birthday;//公有属性
            person.id = id;//私有静态属性
            person.op = function() {//静态方法
                if (age > 20) {
                    alert("你是成年人!");
                }
            }
            function outputstr() {{//私有方法
                alert("a");
            }
            this.input = function() {//公有方法
            person.op();
            }
        }
        person.prototype.isgood = true;//公有属性
        person.high = "high";//私有属性
        var p = new person("sunsanyou", 28, new Date());//实例化
        alert(pe.name + pe.age + pe.birthday);
        alert(p.isgood);
        p.input();

原创粉丝点击