JS Linting the following bit of code:
/*jslint
browser: true,
es5: true,
*/
var VCA = {
get enable () {
'use strict';
return 0;
},
set enable (value) {
'use strict';
console.log(value);
}
};
Results in the error:
Problem at line 11 character 9: Expected 'set' and instead saw ''.
set enable (value) {
I don't understand what to do to make this see 'set'
correctly?!
I know about the __defineGetter__
syntax but really want to use the above style.
Does anyone have more information on this error?
It seems to be a problem in JSLint. I can't get any get/set scenario to validate in JSLint. Your syntax seems to be right, and in line with Douglas' initial post about getter setter validation.
edit: this validates fine, so might be a workaround :-)
var myObject = {};
(function () {
var myProp = 'myDefault';
Object.defineProperty(myObject, 'myProp',
{
enumerable: false,
configurable: true,
get: function () {
return myProp;
},
set: function (value) {
myProp = value + ' lala';
}
});
}());
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With