如果我有一个String实例,并修改其构造函数的原型,那么每个String实例的原型都具有该属性(如预期的那样)。了解Javascript原型链
"test string".constructor.prototype.thing = function() {return this;}
console.log("new string".thing());//prints "new string"
但是,如果我修改字符串构造函数的构造函数的原型,那么这将不再有效:如果
String.constructor.prototype.thing = function() {return this;}
console.log("new string".thing());//returns "new string".thing() is not a function
同样的事情,我使用的字符串。 proto语法。为什么是这样?当我在寻找一个属性时,我的印象是,JavaScript将一直沿着原型链向上。如果我将属性添加到String.constructor.prototype,那么String将不具有该属性,但其父对象将更正?因此,String的所有实例都应该有权访问该属性。我的思想在哪里错了?
可能有[\ _ \ _ proto \ _ \ _ VS的重复。原型在JavaScript](http://stackoverflow.com/questions/9959727/proto-vs-prototype-in-javascript) – rockerest