WEEK 12 Flashcards
The ___ are used to iterate the piece of code using for, while, do while or for-in loops. It makes the code compact. It is mostly
used in array.
JavaScript loops
There are four types of loops in JavaScript.
- for loop
- while loop
- do-while loop
- for-in loop
The ___ iterates the elements for the fixed number of times. It
should be used if number of iteration is known.
JavaScript for loop
The ___ iterates the elements for the infinite number of times. It should be used if number of iteration is not known.
JavaScript while loop
It iterates the elements for the infinite number of times like while loop. But, code is executed at least once whether condition is
true or false.
JavaScript do while loop
___ are used to perform operations. We can call JavaScript
function many times to reuse the code.
JavaScript Functions
Advantage of JavaScript function
- Code reusability
- Less coding
We can call a function several times so it save coding.
Code reusability
It makes our program compact. We don’t need to write many
lines of code each time to perform a common task.
Less coding
We can call function by passing arguments.
JavaScript Function Arguments -
We can call function that returns a value and use
it in our program.
Function with Return Value
In JavaScript, the purpose of Function constructor is to create a new Function object. It executes the code globally.
However, if we call the constructor directly, a function is created dynamically but in an unsecured way.
JavaScript Function Object
It represents the function definition.
functionBody
It is used to call a function contains this value and a single array of arguments
apply ()
It is used to create a new function.
bind()