Вы можете создать экземпляр объекта и затем получить к нему доступ:
function Something() {}
Something.prototype.name = 'javascript';
// create an instance for that
var x = new Something();
console.log(x.name);
//Another set of examples, note the prototype on the objects function has no instance so the getName.protytppe.bucket
const another = {
secret: "skim",
name: "cream",
getName: function() {
return this.name;
},
getSecret: function() {
return this.secret;
},
makeButter: function(n) {
this.name = n;
return `We made {this.name} from cream`;
}
};
another.getName.prototype.bucket = "lot-o-milk"
var n = Object.create(another);
console.log(n.name);
console.log(n.getName());
// make cream into butter
n.name = "butter";
console.log(n.name);
console.log(n.getName());
// turn butter back to cream
delete n.name;
console.log(n.name);
console.log(n.getName());
n.makeButter('yellow');
console.log(n.getName());
console.log(n.getSecret(), n.getName.prototype.bucket);