The docs say the warning happens when:
you use
this
in a non-constructor function. If you forget to use thenew
keyword when calling a constructor function,this
will be bound unexpectedly to the global object in non-strict mode, but will be undefined in strict mode.
Use validethis:true
in a pragma comment:
function addToObject(data) {
'use strict';
var d;
for (d in data) {
if (data.hasOwnProperty(d)) {
/* jshint: validthis:true */
this[d] = data[d];
}
}
}
References