Is it possible to override something on an object in JavaScript to make it seem false?
For example, I create an object like this:
function BusyState() { var self = this; self.isSet = false; self.enter = function () { self.isSet = true; }; self.exit = function () { self.isSet = false; }; }; var isLoading = new BusyState(); isLoading.enter();
I can check the employment like this:
if (isLoading.isSet)
But I would like to write this as a shorthand:
if (isLoading)
Can I do something with my object so that it looks true or false depending on the value of isSet ?
javascript
Paul stovell
source share