Skip to content

Instantly share code, notes, and snippets.

@kotAPI
Last active July 17, 2017 09:47
Show Gist options
  • Save kotAPI/518d8df5635545401ecfe77281e6b64f to your computer and use it in GitHub Desktop.
Save kotAPI/518d8df5635545401ecfe77281e6b64f to your computer and use it in GitHub Desktop.
var Company = function(name,worth){
return{
name:name,
worth:worth,
getNetWorth:function(){
console.log("Name: "+this.name +", Worth :"+this.worth);
},
company2:{
name:"Acquired Company",
worth:"2Bn",
getNetWorth:function(){
console.log("Name: "+this.name +", Worth :"+this.worth);
}
}
}
}
var newCompany=Company("Hex","4Bn");
newCompany.getNetWorth();
// => Name: Hex, Worth :4Bn
newCompany.company2.getNetWorth()
// => Name: Acquired Company, Worth :2Bn
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment