Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVASCRIPT

Default function arguments in ES6

function sort(arr = [], direction = 'ascending') {
  console.log('I'm going to sort the array', arr, direction)
}

sort([1, 2, 3])
sort([1, 2, 3], 'descending')
Source by softhunt.net #
 
PREVIOUS NEXT
Tagged: #Default #function #arguments
ADD COMMENT
Topic
Name
5+6 =