Domanda di colloquio di Flipkart

Q: Write poly-fill for Object.create?

Risposta di colloquio

Anonimo

26 giu 2017

if(typeof Object.create !== "function"){ Object.create = function(proto, properties){ if( (proto === null || typeof proto === "object" || typeof proto === "function")){ throw TypeError("Proto must be Object."); } var tmp = new Object(); tmp.__proto__ = proto; Object.defineProperty(tmp, properties); return tmp ; }; }

1