Data Structures/Closures Flashcards
What does the acronym LIFO mean?
Last In, First Out
What methods are available on a Stack data structure?
push(), pop(), peek()
What must you do to access the value at an arbitrary point in a stack (not just the “top”)?
loop through and iterate through each element top to bottom until you reach desired element
What does the acronym FIFO mean?
first in, first out
What methods are available on a Queue data structure?
dequeue(), enqueue(value), peek()
What must you do to access the value at an arbitrary point in a queue (not just the “front”)?
by using a loop to go through and dequeue elements until you reach the desired element and peek
How are linked lists different from an array?
in a linked list the data are stored individually and are ‘linked’ together while arrays hold data together and are accessed using an index
How would you access an arbitrary node in a linked list (not just the “head”)?
you need to go through the entire list from the head node until you reach the desired node
What are unit tests?
Software where individual units are tested
Why is it important to write unit tests?
For detecting bugs and refining the code quality
What code should be tested with a unit test? What code is not well suited for unit tests?
testing functions and components, it is not well suited for larger blocks of code and for frontend stuff
What is Jest? What are some other popular JavaScript unit testing frameworks?
open-source js testing framework that is used to write unit tests. other testing frameworks include (Mocha, Jasmine, Karma, Ava, etc)
In JavaScript, when is scope determined?
Before the code is executed
What allows JavaScript functions to “remember” values from their surroundings?
Closures
What values does a closure contain?
the function and the object that contains the variables and params of the outer function that were in scope when the inner function was created