Hello i started with closures few days ago and i would like to know if i am on the right path. I ve read a lots of stuff also here but i feel that i need my own example . so this is my example :
var test = {
app: function() {
var a = "asdasd0";
function f() {
document.write(a);
}
test.change();
return f();
},
change: function() {
$("body").css({
"color": "red"
});
}
}
test.app();
Am i right when i am thinking that the function f(){...}; inside test.app is a closure and test.change() also in test.app is a closure? is there anything else ?
Also why test.change() works differently in a codepen(text is red) and jsfiddle(text is not red)? Is it a bad code and jsfiddle has a problem with it ?