I am seeing if there is a build time (using Grunt or maybe JSHint) to only use defined object references. Given this object, throw an error at build (parse) time if referencing an undefined property:
var o = {
foo: 'has a value.',
num: 42
}
console.log('This string ' + o.foo) // Valid
console.log('Summing: ', o.num + o.doesntExistNumber) // Throws an error
For context I want to use this with Angular JS's "constant" service, so the object should be immutable in the application. Any suggestions?