I have an object, which contains lots of other things but I just realised, somehow when I use this I will get undefined or some other things such as this is not a function when it IS a function....
What am I doing wrong here? Can someone please give me a hand?
Here are my sample codes
var global = {
homepage: '/list/',
urlRedirect: function (url) {
window.location.href = url;
},
xButtons: this.homepage,
url: this.urlRedirect('items')
};
console.log(global.xButtons); // gives me undefined
console.log(global.homepage); // gives /list/
global.url // urlRedirect is not a function