oop - Javascript - how to made constructor with config values? -


i have searched plenty of javascript oop libraries, found 1 functionality want. want create javascript object config values :

var iphone = new smartphone({ hastouchscreen: true, operatingsystem: 'ios' });

the 1 library found sencha ext js4 http://docs.sencha.com/ext-js/4-2/#!/api/ext.classmanager

...what magic of create constructor ? or suggest me other oop library can me ? i'm looking free library, because need our commercial application, cannot use free sencha open source projects.

thanks

the magic:

var smartphone = (function smartphoneclass() {    function smartphone(props) {     this.hastouchscreen = props.hastouchscreen || false;     this.operatingsystem = props.operatingsystem || 'android';   }    smartphone.prototype = {     ...   };    return smartphone;  }());  var iphone = new smartphone({   hastouchscreen: true,   operatingsystem: 'ios' }); 

Comments