I've seen code on the web like this (simplified):
var abc = {};
Object.defineProperty(abc, 'example', {
enumerable: 0,
configurable: 1,
writable: 1,
value: function() {}
});
where in place of true
and false
they use 1
and 0
. I prefer this method for its simplicity, but I need to know:
Is this defining format nonstandard and inconsistent across browsers and should be avoided, or is it safe to use in production-level code?
It looks shorter in the code you wrote but having boolean is actually faster in many situations. You would have to write
instead of
same with the use of question marks which I find really nice in some situation:
It's my first answer on the site and I'm a junior developer so I hope it helped!