Tag: bind

function – What is the use of the JavaScript ‘bind’ method?

The Question : 696 people think this question is useful What is the use of bind() in JavaScript? The Question Comments : My standard use case: select = document.querySelector.bind(document) ^And for anyone wondering, the reason that’s needed is because this would otherwise refer to window, the global object. With document.querySelector.bind(document), we ensure that select‘s this