Adding a property to every object property of an object - Javascript Object

Javascript examples for Object:Object Property

Description

Adding a property to every object property of an object

Demo Code

ResultView the demo in separate window

<html>
   <head> 
      <meta name="viewport" content="width=device-width, initial-scale=1"> 
      <script type="text/javascript">
    window.onload=function(){//from  w  w w .jav  a 2 s. c  o  m
function Bar(width) {
    this.foobar = function() {};
    this.width = width
}
Foo = {
    bar1: new Bar('10m'),
    bar2: new Bar('20m'),
    bar3: new Bar()
}
console.log(Foo)
    }

      </script> 
   </head> 
   <body>  
   </body>
</html>

Related Tutorials