if I create an object in JavaScript like so:
var foo = {
create: function(){}
}
will that overwrite the Object.create function?
if I create an object in JavaScript like so:
var foo = {
create: function(){}
}
will that overwrite the Object.create function?
No, it won't.
The object that you create will have a create
method, i.e. foo.create
, but the Object
object still has its own create
function.
Note that the Object.create
function isn't in Object.prototype.create
i.e. it's not a method that exists in any object that is created, it only exists as a property of the Object
function object.
No, because create
is a property of foo
.
For backward compatible Object.create
:
if(!Object.create){
Object.create = function(o){
function F(){}; F.prototype = o;
return new F;
}
}