针对具有不同版本Chrome的相同代码的不同Chrome控制台输出

时间:2015-02-07 19:58:13

标签: javascript google-chrome google-chrome-devtools

我有以下js代码:

var T = function(){};
var tw = new T();
T.prototype.toString = function(){return "1";};

Object.prototype.findOwnerOfProperty = function(propName){
    var currentObject = this;
    while(currentObject !== null){
        if(currentObject.hasOwnProperty(propName)){
            return currentObject;
        } else {
            currentObject = currentObject.__proto__;
        }
    }
    return "No property found!";
};

console.log(tw.findOwnerOfProperty("toString"));

首先,我使用JavaScript引擎V8 3.17.6.15在Chrome 27.0.1453.110上运行它。输出是:

Object {toString: function, findOwnerOfProperty: function}

然后我使用JavaScript引擎V8 3.30.33.16在Chrome 40.0.2214.111上运行它。输出是:

T {toString: function, findOwnerOfProperty: function}

有谁知道为什么输出不同?

0 个答案:

没有答案