Skip to content

Latest commit

 

History

History
32 lines (29 loc) · 1.8 KB

Inheritance.md

File metadata and controls

32 lines (29 loc) · 1.8 KB

Prototype inheritance example

                                  getPrototypeOf/prototype 
                        Function --------------------------
                                                          |
                          ^                               |
                          |                               |
              constructor |                               |
                          |                               |
                          |                               v
                                 getPrototypeOf                         getPrototypeOf
                 function Tree  --------------->  Function.prototype  ----------------------
                                                                                           |
                          ^  |   \                                                         | 
                          |  |    \   prototype                                            |
                          |  |     ----------------                                        |
              constructor |  | new                 \                                       |
                          |  |                     |                                       |
                          |  |                     |                                       |
                          |  v                     v                                       v
             instanceOf          getPrototypeOf                    getPrototypeOf  
    Object  <-----------  tree  --------------->  Tree.prototype  --------------->  Object.prototype  ---->  null
            
                          |
                          |
                   typeof |
                          |
                          v
            
                       "object"