Question

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

No correct solution

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top