0

When executing the following code on Chrome's console, it works as expected:

function printNameWithAdj(adjective) {
    alert(this.name + " is " + adjective);
}

var name = "john";
printNameWithAdj.call(this, "nice");

and it prints "john is nice". But when running it in JSFiddle, it gives "result is nice".

Where does result come from, and what is the reason for the difference between the environments/engines?

j08691
  • 204,283
  • 31
  • 260
  • 272
OfirD
  • 9,442
  • 5
  • 47
  • 90
  • show the JSFiddle... but https://developer.mozilla.org/en-US/docs/Web/API/Window/name – epascarello Nov 04 '16 at 12:15
  • The global object (`window`) on [jsfiddle.com](https://jsfiddle.net/x4yt5fm1/) has a property `name` with the content `"result"` – Andreas Nov 04 '16 at 12:16
  • Thank you all, I didn't know what search terms to look for. – OfirD Nov 04 '16 at 12:19
  • A related one: Why does the value of `window.name` isn't changed in JSFiddle after assigning it a new value (`john`), and it keeps printing `result`? – OfirD Nov 04 '16 at 12:42

0 Answers0