Skip to content

Instantly share code, notes, and snippets.

@hailiang-wang
Created July 7, 2014 05:40
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save hailiang-wang/19a172a35fa59932cf64 to your computer and use it in GitHub Desktop.
Save hailiang-wang/19a172a35fa59932cf64 to your computer and use it in GitHub Desktop.
the quickest way to inherit methods in javascript via prototype
// define a parent
var s = {
print: function(x) {
console.log(x);
}
}
s.print('Hello World');
// now define a heir
var m = {};
// I think this is the quickest way to set s as ancestor
m.prototype = s;
// but it is not
m.print('foo');
@hailiang-wang
Copy link
Author

Some questions about javascript as a lang.

  • what the relationship of function and json
  • what is done when issuing a new
  • is object an json

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment