How best to determine if an argument is not sent to the JavaScript function

后端 未结 13 720
猫巷女王i
猫巷女王i 2020-11-28 00:40

I have now seen 2 methods for determining if an argument has been passed to a JavaScript function. I\'m wondering if one method is better than the other or if one is just ba

13条回答
  •  盖世英雄少女心
    2020-11-28 01:35

    fnCalledFunction(Param1,Param2, window.YourOptionalParameter)

    If above function is called from many places and you are sure first 2 parameters are passed from every where but not sure about 3rd parameter then you can use window.

    window.param3 will handle if it is not defined from the caller method.

提交回复
热议问题