new to javascript: not sure what function (o) means -
what o
?
if not mistaken, prototype means f
going inherit o
, can understand here.
can break down me:
if (!object.create) { object.create = (function () { var f = function(){}; return function (o) { if (arguments.length !== 1) { throw new error('object.create implementation accepts 1 parameter.'); } f.prototype = o; return new f(); }; }());
o
parameter pass function.
for example:
var myobj = object.create({ myfn: function(){} });
then can do:
myobj.myfn();
Comments
Post a Comment