JS Flashcards
How to you store data in localStorage?
localStorage.setItem(‘myCat’, ‘Tom’);
How to you retrieve data from localStorage?
localStorage.getItem(‘myCat’);
What data type can localStorage save in the browser?
only strings
When does the ‘beforeunload’ event fire on the window object?
when the document and it’s resources are about to be unloaded, or closing the browser
What is JSON?
text-based data format following JavaScript object syntax
What are serialization and deserialization?
Serialization is the process of turning an object in memory into a stream of bytes so you can do stuff like store it on disk or send it over the network. Deserialization is the reverse process: turning a stream of bytes into an object in memory.
How do you serialize a data structure into a JSON string using JavaScript?
JSON.Strignify
How do you deserialize a JSON string into a data structure using JavaScript?
JSON.Parse
What is the event.target?
target property of the Event interface is a reference to the object onto which the event was dispatched.
What is the affect of setting an element to display: none?
it makes it invisible and takes it out of document
What does the element.matches() method take as an argument and what does it return?
it takes an argument of css selector, returns a boolean, weather css selector matches the element
How can you retrieve the value of an element’s attribute?
get attribute method
At what steps of the solution would it be helpful to log things to the console?
every step
If you were to add another tab and view to your HTML, but you didn’t use event delegation, how would your JavaScript code be written instead?
you would have to list every tab element with multiple listeners
If you didn’t use a loop to conditionally show or hide the views in the page, how would your JavaScript code be written instead?
you need a list of explicit conditionals,