• Wrong document? Swap it for free
  • Written by students who passed
  • Immediately available after payment
  • Read online or as PDF
Sell
Where do you study
Your language
Document preview thumbnail
Preview 2 out of 6 pages
Exam (elaborations)

Javascript Functions Exam Questions And Answers All Correct

Document preview thumbnail
Preview 2 out of 6 pages

JAVASCRIPT FUNCTIONS EXAM QUESTIONS AND ANSWERS ALL CORRECT

Content preview

JAVASCRIPT FUNCTIONS EXAM
QUESTIONS AND ANSWERS ALL
CORRECT

What is the arity of a function? - Answer-the number of parameters it declares in its
parameter list (read: the number of arguments it expects)

When does a function inherit properties from the prototype object? - Answer-When it is
used as a constructor

What do apply() and call() allow you to do? - Answer-Indirectly invoke a function as if it
were a method of some other object

When is a function recursive? - Answer-A function is recursive if it directly or indirectly
invokes itself

What is a closure? - Answer-A closure is an inner function that has access to the outer
(enclosing) function's variables—scope chain

What three scope chains do closures have access to? - Answer-The closure has three
scope chains: it has access to its own scope (variables defined between its curly
brackets), it has access to the outer function's variables, and it has access to the global
variables.

What is hoisting? - Answer-All variable declarations are hoisted (lifted and declared) to
the top of the function, if defined in a function, or the top of the global context, if outside
a function.

In what order does function declaration, variable declaration or variable assignment take
precedence? - Answer-function declaration takes precedence over variable declarations
(but not over variable assignment).


What is a function? - Answer-A function is a block of Javascript code that is defined
once, but can be executed multiple times.

, What is a function expression? - Answer-it is a variable with a value of a function.

What are parameters? - Answer-A list of identifiers that act as local variables within the
body of the function.

What is a constructor? - Answer-A constructor is a function used for initializing new
objects, and you use the new keyword to call the constructor.

When is a function known as a method? - Answer-When it is assigned to the property of
an object.

When are function names optional? - Answer-For function definition expressions, where
the name refers only to the function object within the body of the function. In essence,
the function name becomes a local variable used within the function. Whereas a
function declaration declares a variable and assigns a function object to it.

What is scope? - Answer-The context in which a variable exists.

What happens if you initialize a variable, but don't declare it inside a local function? -
Answer-It becomes a global variable.

Do local or global variables have priority? - Answer-If you declare a global variable and
a local variable with the same name, the local variable will have priority when you
attempt to use the variable inside a function because the search for a variable with that
name begins inside of the function and moves outward.

What object are all global variables attached to? - Answer-The window object

What happens when you put a function definition inside a conditional (if) block or a
loop? - Answer-Well, don't do that. Different JavaScript platforms in different browsers
have traditionally done different things in that situation, and the latest standard actually
forbids it. If you want your programs to behave consistently, only use this form of
function-defining statements in the outermost block of a function or program.
function example() {
function a() {} // Okay
if (something) {
function b() {} // Danger!
}
}

When is a function the invocation context for an object? - Answer-When a function is
invoked on or through an object

Are function expressions hoisted? If so, can they be invoked anywhere in the code? -
Answer-No, variable declarations are hoisted, but assignments to those variables are
not, so functions defined with expressions cannot be invoked before they are assigned.

Document information

Uploaded on
July 14, 2025
Number of pages
6
Written in
2024/2025
Type
Exam (elaborations)
Contains
Questions & answers
$14.49

Wrong document? Swap it for free Within 14 days of purchase and before downloading, you can choose a different document. You can simply spend the amount again.
Written by students who passed
Immediately available after payment
Read online or as PDF

Seller avatar
Reputation scores are based on the amount of documents a seller has sold for a fee and the reviews they have received for those documents. There are three levels: Bronze, Silver and Gold. The better the reputation, the more your can rely on the quality of the sellers work.
Scholarsstudyguide
3.8
(169)
Sold
853
Followers
476
Items
16410
Last sold
1 week ago




Why students choose Stuvia

Created by fellow students, verified by reviews

Quality you can trust: written by students who passed their tests and reviewed by others who've used these notes.

Didn't get what you expected? Choose another document

No worries! You can instantly pick a different document that better fits what you're looking for.

Pay as you like, start learning right away

No subscription, no commitments. Pay the way you're used to via credit card and download your PDF document instantly.

Student with book image

“Bought, downloaded, and aced it. It really can be that simple.”

Alisha Student

Working on your references?

Create accurate citations in APA, MLA and Harvard with our free citation generator.

Working on your references?

Frequently asked questions