JavaScript Functions Flashcards

1
Q

What is the purpose of a function?

(Define)

A

A set of statements that performs a task or calculates a value. To use a function, you must define it somewhere in the scope from which you wish to call it.

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

A function definition (also called a function declaration, or function statement) consists of the function keyword, followed by:

A
  1. The name of the function.
  2. A list of parameters to the function, enclosed in parentheses and separated by commas.
  3. The JavaScript statements that define the function, enclosed in curly brackets, { }.
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

Give example of function syntax.

A

For example, the following code defines a simple function named square:

function square(number) { return number * number; }

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

What is a return keyword do?

A
  1. It captures the value and returns it.
  2. It also ends the function.
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

Declaration vs Expression

A
  • Declariation
    • Normal Syntax
  • Expression
    • Becomes a function from result of expression (blahblah var = function ()
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

When functions run… what do they return?

A

Whatever is defined in return

If no return keyword is present it is undefined

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

Names of:

  1. ” “
  2. ( )
  3. { }
  4. []
  5. | |
  6. //
  7. \
A
  1. Quotes
  2. Parenthesis
  3. Braces
  4. Brackets
  5. Vertical Bar
  6. Forward Slashes (Comment - JS)
  7. Back slash - Show following charachter
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q
A
How well did you know this?
1
Not at all
2
3
4
5
Perfectly