WEB PROGRAMMING MIDTERM
(JAVASCRIPT) STUDY QUESTIONS
AND ANSWERS
Where is JavaScript interpreted? - ANSWER-Browser and Node.js
in operator - ANSWER-checks if a property exists in an object
... rest syntax - ANSWER-used to collect remaining properties after
deconstruction
extracts the property specified and the remaining properties are collected in
rest
for/in - ANSWER-used to enumerate individual properties of an object
works with any object after the 'in'
if the object is null, skips the loop
arrow functions - ANSWER-functions without keyword
useful when passing a function as an argument to another function
spread operator - ANSWER-allows us to quickly copy all or part of an existing
array or object into another array or object (...)
for/of - ANSWER-runs once for each element
works with arrays, strings, sets, and maps
forEach - ANSWER-iterates through an array invoking a function you specify
for each element.
, example:
data = [1,2,3,4]
data.forEach( (v,i,a) => a[i] = v + 1);
// data = [2,3,4,5]
map() - ANSWER-passes each element of the array on which it is invoked to
the function you specify
returns a a new array
filter() - ANSWER-creates a new array with all elements that pass the test
implemented by the provided function
function passed should be true or false
sort() - ANSWER-sorts the elements and returns a sorted array
sorts in place
reduce - ANSWER-combines the elements of an array using function given to
produce a single value
higher order function - ANSWER-outer function that takes in a function
functions that accept functions as arguments
callback function = function inserted into function
Document Object Model - ANSWER-used to change/modify the HTML
document
document object - ANSWER-root node of the HTML document
(JAVASCRIPT) STUDY QUESTIONS
AND ANSWERS
Where is JavaScript interpreted? - ANSWER-Browser and Node.js
in operator - ANSWER-checks if a property exists in an object
... rest syntax - ANSWER-used to collect remaining properties after
deconstruction
extracts the property specified and the remaining properties are collected in
rest
for/in - ANSWER-used to enumerate individual properties of an object
works with any object after the 'in'
if the object is null, skips the loop
arrow functions - ANSWER-functions without keyword
useful when passing a function as an argument to another function
spread operator - ANSWER-allows us to quickly copy all or part of an existing
array or object into another array or object (...)
for/of - ANSWER-runs once for each element
works with arrays, strings, sets, and maps
forEach - ANSWER-iterates through an array invoking a function you specify
for each element.
, example:
data = [1,2,3,4]
data.forEach( (v,i,a) => a[i] = v + 1);
// data = [2,3,4,5]
map() - ANSWER-passes each element of the array on which it is invoked to
the function you specify
returns a a new array
filter() - ANSWER-creates a new array with all elements that pass the test
implemented by the provided function
function passed should be true or false
sort() - ANSWER-sorts the elements and returns a sorted array
sorts in place
reduce - ANSWER-combines the elements of an array using function given to
produce a single value
higher order function - ANSWER-outer function that takes in a function
functions that accept functions as arguments
callback function = function inserted into function
Document Object Model - ANSWER-used to change/modify the HTML
document
document object - ANSWER-root node of the HTML document