I saw examples of 2 types of bind calls. first kind is:
const book = {
title: 'Brave New World',
author: 'Aldous Huxley',
}
function summary() {
console.log(`${this.title} was written by ${this.author}.`)
}
const braveNewWorldSummary = summary.bind(book)
now "this" in summary is now bond to the "book" object
the second kind is:
function utilizationUpdate(chart, data) {....}
function utilizationInit(component, btnGroup, data){
....
var myChart = new Chart(ctx, {....}
$(btnGroup).on("change", function() {
...
fetch('{% url 'api_utilization' fac.fac_id %}?measure=' + measure + '&{{ request.GET.urlencode() }}' )
.then(status)
.then(json)
.then(utilizationUpdate.bind(this, myChart));
}
});
}
"chart" in utilizationUpdate() is now bond to myChart.
Why in first bind() example, "this" is not an argument to be passed? but it is specified in the second bind() example?