Closure in Javascript with multiple brackets

前端 未结 5 588
梦谈多话
梦谈多话 2021-02-01 21:00

Could any one explain how this function alert, when more no of brackets of parameters are passed. I could not able to understand it clearly.

function sum(a) {

          


        
5条回答
  •  盖世英雄少女心
    2021-02-01 21:43

    alert expects a string. If it doesn't get a string, it will attempt to convert whatever object it receives (and a function is a type of object) into one. If the object has a toString method, then that will be called to perform said conversion.

提交回复
热议问题