Skip to main content
Stack Overflow
  1. About
  2. For Teams

Timeline for Optional parameters in JavaScript [duplicate]

Current License: CC BY-SA 3.0

Post Revisions

15 events
when toggle format what by license comment
Nov 25, 2016 at 22:34 history closed Michał Perłakowski javascript Users with the javascript badge or a synonym can single-handedly close questions as duplicates and reopen them as needed. Duplicate of Set a default parameter value for a JavaScript function
Apr 12, 2013 at 16:38 answer added zVictor timeline score: 0
Jun 14, 2012 at 10:16 vote accept Richard
Jun 14, 2012 at 10:12 answer added Sepehr timeline score: 1
Jun 14, 2012 at 9:32 comment added Simon Forsberg In addition to Felix' comment I would like to add that null is a value of the type object. Specifying null as an argument is not the same as an unspecified argument. Btw, another way to call the method is checkParamIsBoolean(); (this is basically the same as your last example)
Jun 14, 2012 at 9:30 answer added sbgoran timeline score: 14
Jun 14, 2012 at 9:28 answer added Anthony timeline score: 0
Jun 14, 2012 at 9:26 comment added Simon Forsberg You say that you want to use default value for optional parameter, and yet only the last call to the checkParamIsBoolean is not setting the parameter. All the other calls, even when you use null as the argument, is setting a value for the parameter.
Jun 14, 2012 at 9:24 answer added Niclas Sahlin timeline score: 1
Jun 14, 2012 at 9:24 answer added Mariusz Jamro timeline score: 25
Jun 14, 2012 at 9:20 answer added floorish timeline score: 2
Jun 14, 2012 at 9:20 answer added Bergi timeline score: 1
Jun 14, 2012 at 9:17 comment added Felix Kling There are many related questions about this topic already (example). Have a look at all the ones on the right side. If you ask why you don't get the expected outcome, this is because null and undefined are falsy and boolean operators return the value of the variable that determines the outcome of the expression.
Jun 14, 2012 at 9:16 answer added Simon Forsberg timeline score: 3
Jun 14, 2012 at 9:13 history asked Richard CC BY-SA 3.0

AltStyle によって変換されたページ (->オリジナル) /