Consider this simple code:
"use strict"; var obj = { f: function() { this.prop = 'value'; g.bind( this )(); } }; function g() { console.log( this.prop ); }
If I try to check this code, jshint gives me a Possible strict violation. error Possible strict violation. where I call console.log( this.prop ); . This is because this undefined is in strict mode in a function.
But I bind this function before calling it, so this is the right object.
I use this “design pattern” to avoid cluttering the main object. Passing properties in parameters also clutters the function, so I refuse to do this. Also, this is exactly what bind for.
Is there a way for JSHint to let me do this?
javascript jshint
Florian Margaine Aug 21 2018-12-12T00: 00Z
source share