문제

I rather like the prototype way of programming and have been trying to understand it in javascript.

I saw this bit of code in The Good Parts:

function beget(o){
  function F(){
    F.prototype = o;
  };
  return new F();
};

I don't get this at all lol. If all you have to do is set the prototype to a past object, then couldn't you just do this:

var parent = {
  num = 66;
};
var child = {
  prototype: parent
};

This doesn't seem to work though, cause child.num is returned as undefined. How do you describe javascript prototype programming and what are your methods? Thanks guys

올바른 솔루션이 없습니다

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top