With javascript:
function myFunc() {
var x = 5;
};
console.log(x);
I get //undefined
and with:
function myFunc() {
x = 5;
};
console.log(x);
I get 5
With coffeescript
this variable var x = 5;
is x = 5
.
For example this is possible?:
myFunc ->
window.x = 5;
console.log window.x
Instead of:
myFunc ->
x = 5;
console.log x
My question is How I can differentiate a global variable of a local variable with CoffeeScript?