I was trying out the below question in ES6 learning material
const circle = {
radius: 10,
color: 'orange',
getArea: function() {
return Math.PI * this.radius * this.radius;
},
getCircumference: function() {
return 2 * Math.PI * this.radius;
}
};
let {radius, getArea, getCircumference} = circle;
console.log(getArea())
At first I thought the result printed to be 314.1592653589793
but turns out the result printed is NaN
. Which mean that the getArea()
function does not have access to this
. Why does the function do not have access to this
while de-structuring the Object ?