I just wondered why this code run correctly with normal function and resulted in a different result when using arrow function:
the code:
String.prototype.addDotAfter = function() {
return `${this}.`;
}
let ahmed = 'ahmed';
console.log(ahmed.addDotAfter()) // = ahmed.
the other code that return strange result:
String.prototype.addDotAfter = ()=> {
return `${this}.`;
}
let ahmed = 'ahmed';
console.log(ahmed.addDotAfter()) // = [object Object].
I don't know why they are different in result!