Skip to content

Latest commit

 

History

History
22 lines (16 loc) · 831 Bytes

what_are_the_function_parameter_rules.md

File metadata and controls

22 lines (16 loc) · 831 Bytes

What are the function parameter rules?

  • Function parameters are the variables listed in a function's declaration.
  • JavaScript functions can have default parameters.
  • Parameters are passed in the order they are listed.
  • A function can accept any number of arguments, but the excess arguments will be ignored unless using the ...rest parameter.

Example:

function greet(name = 'Guest') {
  console.log('Hello, ' + name);
}
greet(); // 'Hello, Guest'
greet('John'); // 'Hello, John'

Tags: basic, JavaScript, functions

URL: https://www.tiktok.com/@jsmentoring/photo/7459895386811976992