Created
April 27, 2020 18:02
-
-
Save glaszczak/5cd3f7c8222fecca2cd26bae7a9209da to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Me { | |
constructor(userName, friend) { | |
this.userName = userName; | |
this.friend = friend; | |
} | |
getName() { | |
console.log(`This is ${this.userName}`); | |
} | |
getFriend() { | |
console.log(this.friend); | |
} | |
} | |
class Friend { | |
constructor(friendName, otherFriend) { | |
this.friendName = friendName; | |
this.otherFriend = otherFriend; | |
} | |
static logFriendName() { | |
console.log(this.friendName); | |
} | |
logOtherFriend() { | |
console.log(this.otherFriend); | |
} | |
} | |
class OtherFriend { | |
constructor(otherFriendName) { | |
this.otherFriendName = otherFriendName; | |
} | |
logOtherFriendName() { | |
console.log(this.otherFriendName); | |
} | |
} | |
const me = new Me("Me", new Friend("Friend", new OtherFriend("Other Friend"))); | |
me.getFriend(); // returns: Friend {friendName: 'Friend', otherFriend: OtherFriend { otherFriendName: 'Other Friend' } } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment