Functions Javascript

[Q.1] - (function() { return (() => this.x).bind({ x: ‘inner’ })(), (() => this.x)() }).call({ x: ‘outer’ });

I don’t understand this question and how it’s working. please explain.

[Q.2] - function constfuncs() { var funcs = []; for(var i = 0; i < 10; i++) funcs[i] = function() { return i; }; return funcs; } var funcs = constfuncs(); funcs5 What does the last statement return ?

It should return 4 because there in the array of “funcs” at index of 5 there will be 4.

[Q.3] - function f(){ return f; } new f() instanceof f; What is the output?

Please explain.

Hi @theonlyritik_3b4a4a5eb9f6c783,

  • Ans 1 : To understand the bind function please visit link . The value to be passed as the this parameter to the target function func when the bound function is called. If the function is not in strict mode, null and undefined will be replaced with the global object, and primitive values will be converted to objects. The value is ignored if the bound function is constructed using the new operator.

  • Ans 2 : Did’nt really get your question please be clear with the function code and the question you are trying to ask.

  • Ans 3 : This will return false as we are checking if new instance of f is the instance of the existing function f hence false is returned.

I hope I’ve cleared your doubt. I ask you to please rate your experience here
Your feedback is very important. It helps us improve our platform and hence provide you
the learning experience you deserve.

On the off chance, you still have some questions or not find the answers satisfactory, you may reopen
the doubt.

Hi Malya, thanks for the replies. Everytime you mentioned link. I first tried myself to solve questions by googling or anyhow and then if I don’t understand, I ask. But your answers is like I am reading it from google again. Can you make it more clear please so that as fresher I can understand better. Also for the [Q.2] it’s exact question I had copied and pasted from the [WD.2] Quiz on Functions.