$.fn.anyFunction = () => {
console.log(this == window);
return this;
}
$(document).ready(() => {
$('div').anyFunction(); // true
});
function blablabla() {
$.fn.anyFunction = () => {
console.log('compare to window: ', this == window); // false
console.log('compare to blablabla: ', this instanceof blablabla); // true
console.log(this); // blablabla {}
return this;
}
}
$(document).ready(() => {
var b = new blablabla();
$('div').anyFunction();
});