I was playing around with Javascript with this code snippet:
function personDetails(age) {
var param = "The age of " + this.name + ' is ' + age;
return param;
}
var details = personDetails(26);
console.log(details);
'this' is not defined for the function. (yes the function should be used with call and apply methods).
But I am curious about the fact that, I am getting different outputs when I run it in terminal, browser(loading via a .html file) and fiddle.
Running in terminal using node gives the o/p: The age of undefined is 26.
Running in browser(loading via a .html file): The age of is 26.
Running in Fiddle: The age of result is 26.
I am curious about why "undefined" in terminal, why nothing in browser and why "result" in fiddle.