Created
April 13, 2024 02:13
-
-
Save madhoshyagnik/b272fa540aa9b73512be3280e2712b54 to your computer and use it in GitHub Desktop.
This file contains 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
//arrow functions DO NOT WORK inside an object, if arrow function is user the window context is set for that method | |
let user = { | |
name: 'crystel', | |
age: 30, | |
email: '[email protected]', | |
location: 'berlin', | |
blogs: ['why mac and cheese rules', ['10 things to make with marmite']], | |
login: function(){ | |
console.log('user logged in'); | |
}, | |
logout: function(){ | |
console.log('the user is logged out') | |
}, | |
logBlogs: function(){ | |
console.log('this user has written following blogs'); | |
this.blogs.forEach(blog => { | |
console.log(blog); | |
}) | |
} | |
}; | |
user.logBlogs(); | |
user.login(); | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment