DEV Community

Discussion on: Introduction to JavaScript Arrow Functions

Collapse
 
umutahmet profile image
Umut Ahmet

Hey mate, nice article :)

Just a note on the this within a method in an object - there is also a shorthand way of writing a function in ES6 so this works correctly:

const person = {
    firstName: 'Mike',
    lastName: 'Lilly',
    fullName() {
        return `${this.firstName} ${this.lastName}`;
    }
};

person.fullName(); // Mike Lilly