Learning Javascript : Object Creation Patterns

Reading Time: 2 minutes

There are majorly Four patterns to create an Object in Javascript.

  • Constructor Pattern.
  • Factory Pattern
  • Prototype Pattern
  • Dynamic Prototype Pattern.
  • Use this keyword to attach
  • Don’t return anything.
  • Create Dummy Object
  • Return this object after 
Prototype Pattern
  • Put things in Shared space (Prototype).
  • Kind of assign default values.
Dynamic Prototype Pattern. – http://jsbin.com/tajiwof/edit?js,console
// Dynamic Prototype Pattern  – Object Creation

Lexical Scoping 
Inner Function Automatically has the Outside variables access.
// Lexical Scoping  – Inner Functions have access to OUTER Variables
Closure in Javascript

Leave a Comment

This site uses Akismet to reduce spam. Learn how your comment data is processed.

0 Shares
Tweet
Share
Pin
Share
+1