Encapsulation Group similar data methods Hide protect functionality data both for security and future upgrades modifications Factory Function Encapsulation function Box let color blue this is private this height 2 this zoom function console log zooming this height color let box new Box box zoom console log height box height valid value console log color box color undefined null Class Notation Encapsulation class Box constructor let color blue private this height 2 this zoom function console log zooming this height color close console log zooming this height end class Box let box new Box box zoom box close console log height box height valid value console log color box color undefined null Object Mapping Encapsulation function makeBox boxType let box box boxType boxType let color blue private box height 2 box zoom function console log zooming box height color return box let box makeBox test box zoom console log height box height valid value console log color box color undefined null Static inline object mapping let box height 2 zoom function let color blue private console log zooming box height color box zoom console log height box height valid value console log color box color undefined null
box close console log height box height valid value console log color box color undefined null Object Mapping Encapsulation function makeBox boxType let box box boxType boxType let color blue private box height 2 box zoom function console log zooming box height color return box let box makeBox test box zoom console log height box height valid value console log color box color undefined null Static inline object mapping let box height 2 zoom function let color blue private console log zooming box height color box zoom console log height box height valid value console log color box color undefined null