Use Default Parameters #3
                
     Open
            
            
          
  Add this suggestion to a batch that can be applied as a single commit.
  This suggestion is invalid because no changes were made to the code.
  Suggestions cannot be applied while the pull request is closed.
  Suggestions cannot be applied while viewing a subset of changes.
  Only one suggestion per line can be applied in a batch.
  Add this suggestion to a batch that can be applied as a single commit.
  Applying suggestions on deleted lines is not supported.
  You must change the existing code in this line in order to create a valid suggestion.
  Outdated suggestions cannot be applied.
  This suggestion has been applied or marked resolved.
  Suggestions cannot be applied from pending reviews.
  Suggestions cannot be applied on multi-line comments.
  Suggestions cannot be applied while the pull request is queued to merge.
  Suggestion cannot be applied right now. Please check back later.
  
    
  
    
Default parameters allow providing default values for function parameters. These default values are used if nothing or
undefinedis passed into the function. For example,function f(p = 42) { ... }setspto42if no value is passed in.Previous ways of setting default values, for example
p = p || 42can be converted to default parameters. This refactoring supports converting the following expressions and variants of them:p = p || 42orp ||= 42p = p ?? 42p = p ? p : 42nullcheck, e.g.p = p == null ? 42 : porp = p != null ? p : 42undefinedcheck, e.g.p = p === undefined ? 42 : ptypeofcheck, e.g.p = typeof p === "undefined" ? 42 : pDefault values are only used in place of
undefined. In the expressions that are replaced with default values, falsy ornullvalues may have been replaced as well. This may lead to undesired behavior.