How to pass the value 'undefined' to a function with multiple parameters?

前端 未结 12 2191
滥情空心
滥情空心 2020-12-14 14:26

I want to pass the value of \'undefined\' on a multiple parameter function but without omitting the parameter.

What do I mean with \"without omitting the paramet

12条回答
  •  萌比男神i
    2020-12-14 14:41

    An easy way of doing this, when acceptable is to pass undefined. But better yet as follows per W3C

    Javascript-missing arguments

    function myFunction(x, y) {
    if (y === undefined) {
          y = 0;
        } 
    }
    

提交回复
热议问题