Friday, May 17, 2024
 Popular · Latest · Hot · Upcoming
90
rated 0 times [  92] [ 2]  / answers: 1 / hits: 67636  / 13 Years ago, wed, january 25, 2012, 12:00:00

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 parameter. I mean that we should not just omit the parm2 like this example:



function myFunction (parm1, parm2) {}
myFunction(abc);


This will indeed make parm2 undefined, but I am not allowed to do it this way because I will need to specify other parameters AFTER the omitted parameter, so the previous method won't work in the case I want to make parm1 undefined BUT also want to have other parameters after this one to hold a value.



I have tried solving the problem with:



myFunction( ,abc); //doesn't seem to work





Update:





and myFunction(undefined, abc); « this reliably works now.



However, it is worth mentioning that:




Setting a variable to undefined is considered a bad practice, we
should be using null instead.



More From » function

 Answers
12

myFunction(undefined,abc); this way should work, what is the problem?



see here



Here is undefined documentation from mozilla, supported by all browsers


[#87817] Monday, January 23, 2012, 13 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
taylert

Total Points: 627
Total Questions: 91
Total Answers: 108

Location: Mayotte
Member since Mon, Sep 12, 2022
2 Years ago
taylert questions
;