Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <html>
- <head>
- <title>Ohi</title>
- <script>
- test = { "People": { }, 'addPerson': function ( sName ) { this.People[ sName ] = new Person( sName ); } }
- test.addPerson( 'Fred' );
- function Person( sName )
- {
- this.sName = sName;
- this.Hats = [];
- var oPar = this;
- this.Hats[ "Red" ] = new Hat( oPar, "red" );
- this.Hats[ "Yellow" ] = new Hat( oPar, "yellow" );
- }
- function Hat( oParent, sColor )
- {
- this.parent = oParent;
- this.sColor = sColor;
- this.changeColor = function( sNewColor )
- {
- this.sColor = sNewColor;
- return true;
- }
- this.OwnerName = function ( )
- {
- return this.parent.sName;
- }
- }
- console.log( test.People[ "Fred" ] );
- console.log( test.People[ "Fred" ].Hats );
- console.log( test.People[ "Fred" ].Hats.length );
- </script>
- </head>
- <body>
- Ohi
- </body>
- </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement