Got a minute for some JavaScript? ⌨️ What does this code output? Answer 🔍 >>> 105 When using *call*, all arguments after the first one are passed to the function parameters. Unlike *apply*, you don’t need to pass them as an array. Here, a single array [5] is passed, so a becomes [5]. When adding a number and an array in JavaScript, the array is converted to a string, and concatenation occurs. #javascript #webdevelopment
Call() sets this to {base:10}. The argument [5] is an array, which is converted to string "5" durring addition. So the expression becomes 10 + "5", resulting in "105" due to type coercion.
Ans : 105 call() sets this to { base: 10 }, but [5] turns into "5" during addition. Number + string = string concatenation.
ESLint exists for a reason.
105
105
105
15
105
105... becos..[5] gets coerced to '5'.. so it becms strng concatenation (10 + '5')..