I have an empty .js file with this code in it:
Cart.CheckoutNow = {
...
}
// Alias
if (typeof(CheckoutNow) === 'undefined') {
CheckoutNow = Cart.CheckoutNow;
}
else {
alert('CheckoutNow is already a variable in window.');
}
How can I have the // Alias
code appear at the top of the page, but have it execute after Cart.CheckoutNow is declared?
This would work, but I don't like that you have to call alert() at the bottom:
alias = function() {
if (typeof(CheckoutNow) === 'undefined') {
CheckoutNow = Cart.CheckoutNow;
}
else {
alert('CheckoutNow is already a variable in window.');
}
};
Cart.CheckoutNow = {
...
};
alias();