hasOwnProperty

/*
    
    var N = function () {
        this.keys = [];
        this.w = {};
        this.m = {}
    };
    N["prototype"].set = function (a, b, c) {
        this.keys["push"](a);
        c ? this.m[":" + a] = b : this.w[":" + a] = b
    };
    N["prototype"].get = function (a) {
        return this.m["hasOwnProperty"](":" + a) ? this.m[":" + a] : this.w[":" + a]
    };
    N["prototype"].map = function (a) {
        for (var b = 0; b < this.keys["length"]; b++) {
            var c = this.keys[b],
                d = this.get(c);
            d && a(c, d)
        }
    };


    var x = new N;

    x.set("key", "value", true);

    var v = x.get("key");

    window.alert(v);*/

        var c = function () {
            this.name = "";
            this.x = {};
            this.ok = function () {
                window.alert('ok');
            }
        };

        c.prototype.setname = function (name) {
            

            this.x["h"] = name;
        }

        c.prototype.getname = function () {
            if (this.x.hasOwnProperty("h")) {
                return this.x["h"];
            }

            //window.alert("none");
            return "None";
        }
 

        var x = new c;

        x.setname('zbw');

        window.alert(x.getname());


        x.setname(function() {
            window.alert("e");
        });


       var c =  x.getname();

        c();
原文地址:https://www.cnblogs.com/zbw911/p/4062848.html