So I’ve got an object, or array, declared at the beginning of anything, outside everything:
var Thing = {title:'horse'};
Then I’ve got:-
$('.clickedIt').fadeOut(200, function() { console.log(Thing.title); }
That will fail. However, if I place above that same console log out of fadeOut, it’ll be fine.
If you want something to be global, just define it on the
windowObject.Then use it like so:
Just a note, putting a number of variables on the
windowObject is not recommended, I would recommend looking into name-spacing: http://addyosmani.com/blog/essential-js-namespacing/Here is an example: