I would stick to something like: boolParam = (typeof boolParam === 'undefined' ? true : boolParam);
On Oct 21, 4:18 pm, HankyPanky <[email protected]> wrote: > I want my function to have one parameter, namely boolParam, which has > a default value of TRUE; > In the first place, it seems that the following snippet will do, but > it's absolutely wrong and boolParam will always set to TRUE even if a > false value is passed to the function; > > What's your solution to this using this pattern? > > funtion myFunc(boolParam) { > boolParam = boolParam || true; > /*rest of the code*/ > > > > > > > > } -- To view archived discussions from the original JSMentors Mailman list: http://www.mail-archive.com/[email protected]/ To search via a non-Google archive, visit here: http://www.mail-archive.com/[email protected]/ To unsubscribe from this group, send email to [email protected]
