Last active
May 12, 2020 06:32
-
-
Save prof3ssorSt3v3/14107ed915d09ccd77c8b2a8012a265b 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
// Using `this` inside an object | |
// The object has functions created three different ways | |
// What will be the result of the three log statements? | |
const circle = { | |
radius: 10, | |
circumference: function () { | |
return (2 * Math.PI * this.radius); | |
}, | |
diameter() { | |
return (this.radius * 2); | |
}, | |
area: () => { | |
return (Math.PI * Math.PI * this.radius); | |
} | |
} | |
console.log(circle.area()); // | |
console.log(circle.diameter()); // | |
console.log(circle.circumference()); // |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment