I noticed that this
returned from bound function doesn't strictly equal primitive value passed when binding.
According to MDN when the original function is called [[BoundThis]]
gets passed.
What is this
returned from bound function? Is it [[BoundThis]]
?
const fn = function() { return this }
const strBound = fn.bind('111')
const numBound = fn.bind(111)
const boolBound = fn.bind(true)
console.log(strBound()) // [String: '111']
console.log(strBound() == '111') // true
console.log(strBound() === '111') // false
console.log(numBound()) // [Number: 111]
console.log(numBound() == 111) // true
console.log(numBound() === 111) // false
console.log(boolBound()) // [Boolean: true]
console.log(boolBound() == true) // true
console.log(boolBound() === true) // false