Javascript Prototype

javascript basic series - level 1 - 10%

Created by xiad / xiadong8@wanda.cn

Agenda

  • History
  • Prototypal inheritance
  • Object & Function
  • Relationships map*
    • Object, Function, function, object
  • Practice for fun
  • Next step
  • Q & A

History

  • May 1995, by Brendan Eich, in 10 days
  • Faults, quirks, mistakes
  • Language of web
  • Object oriented?
  • Class? this? new?

Prototypal

  • No class
  • Everything is object
  • Question:
    • Object.create

Object & Function

  • Object
    • json
    • String, number, boolen, null, undefined, NaN
    • __proto__
  • Function
    • Prototype

Relationships

  • typeof
  • hasOwnProperty

Relationships*

  • Object.prototype
  • Function.prototype
  • Object
  • Function
  • function f1() {}
  • {}
  • Object.new
  • new f1()
  • constructor
							
								function Person() {}
								new Person();
							
						

For fun

  • Object.constructor === ?
  • ...
							
								Object.constructor === Function
							
						

Next Step

  • String, Number, Array
  • Regular Expression
  • this & invocation pattern
  • Scope
  • Closure*
  • Inheritance
  • Design pattern

Q & A