Functions review
Lets review functions!
What happens if....
I don't have a
return
at all in the function?I try to
console.log(num1)
outside the function? After the function? After the function is called?What if I use
const
orlet
to create a variable inside the function?How many parameters can I have?
What happens if I put some code after the
return
?
How do I return multiple bits of information from a function? Build this function:
The transform it into this function, returning an object:
Arrow functions
An arrow function expression is a compact alternative to a traditional function expression, with some semantic differences and deliberate limitations in usage:
Arrow functions cannot be used as constructors.
Syntax
Now lets rewrite the above function as an arrow function
One more example, let write a function to multiply two numbers
Try rewriting functions you've using the arrow function syntax =>
References
Last updated
Was this helpful?