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
| let sergiosTasks = { | |
| tasks: ['study oop javascript', 'prepare for sysops exam', 'read linux book', 'write article'], | |
| getTasks() { | |
| console.log('Today I have to:') | |
| this.tasks.forEach((task, index) => { | |
| console.log(`(${index + 1}) ${task}`); | |
| }) | |
| } | |
| } |
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
| let schittsCreekData = { | |
| data: { | |
| cast: ["Daniel Levy", "Eugine Levy", "Annie Murphy", "Catherine O'Hara"], | |
| category: 'TV Series', | |
| episodes: 80, | |
| releaseDate: '2015', | |
| genre: 'Comedy', | |
| keywords: ['motel', 'small', 'family', 'riches to rages'] | |
| } | |
| } |
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
| const user = { | |
| firstName: 'Roland', | |
| lastName: 'Schitt', | |
| username: function() { | |
| return this.firstName + this.lastName; | |
| } | |
| } | |
| // const getUsername = user.username; // NaN | |
| const getUsername = user.username.bind(user); |
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
| const roland = { | |
| fullName: 'Roland Schitt', | |
| job: "Schitt's Creek Mayor" | |
| } | |
| function getInformation(occupation) { | |
| return `${this.fullName}, ${occupation}.`; | |
| } | |
| console.log(getInformation.apply(roland, [roland.job])); |
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
| // pattern for a function using the `apply` method | |
| aFunction.apply(context, [arg1, arg2, arg3]) | |
| // pattern for a method using the `apply` method | |
| anObject.aMethod.apply(context, [arg1, arg2, arg3]) |
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
| global.roseFamily = ['David', 'Alexis', 'Moira', 'Johnny']; | |
| function welcome() { | |
| this.roseFamily.forEach(member => { | |
| console.log(`Welcome to Schitt's creek ${member}!`); | |
| }); | |
| } | |
| welcome.call() |
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
| function User(name, email, course) { | |
| this.name = name; | |
| this.email = email; | |
| this.course = course; | |
| } | |
| function Student(name, email, course, registered) { | |
| User.call(this, name, email, course); | |
| this.registered = registered; | |
| } |
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
| const data = { | |
| firstName: 'Johnny', | |
| lastName: 'Rose', | |
| greeting: 'Good morning!' | |
| } | |
| function introduce() { | |
| return `${this.greeting}! I'm ${this.firstName} ${this.lastName}!`; | |
| } |
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
| // pattern for a function using the `call` method | |
| aFunction.call(context, arg1, arg2, arg3) | |
| // pattern for a method using the `call` method | |
| anObject.aMethod.call(context, arg1, arg2, arg3) |
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
| "use strict"; | |
| const user = { | |
| firstName: 'Ronald', | |
| lastName: 'Schitt', | |
| username: function() { | |
| return this.firstName + this.lastName; | |
| } | |
| } |