why bind arguments are not pointed to actual function parameters

后端 未结 1 911
一向
一向 2021-01-26 09:50

why limit is 20 rather than el=20 because in isFullAge.bind(this,20) in which 20 is the last argument ,so it has to pass to \'el\' parameter,but why it is set to \'limit\' param

相关标签:
1条回答
  • 2021-01-26 10:37

    The first argument becomes the this value. Each subsequent value is mapped onto the arguments in order, left to right. They are not assigned from the end backwards.

    20 is the first argument after the this value in the call to bind so it is assigned to limit because limit is the first argument.

    Had you said:

    isFullAge.bind(this, 20, example))
    

    … then example would be assigned to el because el is the second argument and example would be the second argument after the this value.

    0 讨论(0)
提交回复
热议问题