I need to make a change but continue providing backwards-compatibility for some time, but I can't figure out how to accomplish this.
I have an Object like this:
MyObject = (function() {
// vars here and there
var myVar
// a bunch of code
return {
get myVar() { return myVar },
myVar: function() { return myVar }
}
}())
This doesn't work. I want to be able to get myVar both with
MyObject.myVar
and
MyObject.myVar()
Is it possible? Even better, is there any possibility to accomplish that and make it cross-browser compatible? (Right now I know the get notation is not supported by Internet Explorer)
Thanks.
UPDATE:
Because it seems not possible, is there any way to make what I have now, get myVar() browser-compatible with Internet Explorer?
So all browsers can access MyObject.myVar
As long as I can continue providing a getter to myVar and it's compatible with Internet Explorer, there is no need to move to myVar() but I couldn't find a feasible solution to make the current way (MyObject.myVar) compatible other than moving to a function-like getter.