So I've been trying to learn a bit about JS context and understanding the "this" keyword. This is some code I've been working with:
var addNumbers = function(num1, num2){
console.log(num1+num2);
}
var newAdd = addNumbers.bind(this,1,2);
newAdd();
The above logs the value 3, as it should. But if I call addNumbers.bind without the "this" keyword:
var newAdd = addNumbers.bind(1,2);
The newAdd() call returns NaN. Why does this NaN happen? and also, I only came across the solution of adding "this" as a first parameter by trying things out and not necessarily out of intuition. Why does passing "this" as a parameter work? and what context does the "this" in this case represent? Thanks.
EDIT: This question is different from any .bind() related questions because It is not asking for a general explanation of this function. I am asking about a specific use case and need a specific answer. Other suggested duplicates were more generalized and were more open to different types of answers.