javascript-functions-intro Flashcards

1
Q

What is a function?

A

set of code that can be grouped together and reused.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

Why are functions useful?

A

Allow you to store a piece of code that does a single task inside a defined block, and then call that code whenever you need it using a single short command

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

How do you call a function?

A

a method with an owner object as an argument (parameter)

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

What are the parts of a function definition?

A
  1. keyword
  2. optional name
  3. parameters()
  4. statement enclosed in braces {}
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

What is the difference between a parameter and an argument?

A

Function parameters are the names listed in the function’s definition. Function arguments are the real values passed to the function.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly