HTML Flashcards
Where do you put non-visible content about the HTML document?
In the Head tag
Where do you put visible content about the HTML document?
Body tag
Where do the and tags go in a valid HTML document?
Inbetween and
What is the purpose of a declaration?
State the kind of document it is
Give five examples of HTML element tags.
h1 p br body h2
What is the purpose of HTML attributes?
To define actions and parameters with in the elements.
Give an example of an HTML entity (escape character).
& is used to create an ampersand.
How do block-level elements affect the document flow?
Create sections for different content vertically
How do inline elements affect the document flow?
Create sections for different content horizontally
What are the default width and height of a block-level element?
Default width is the view port. Default height is bound by the above and below block.
What are the default width and height of an inline element?
Width is bound my the neighboring inline elements. Height is defined by the space it content takes.
What is the difference between an ordered list and an unordered list in HTML?
Number and bullet points
Is an HTML list a block element or an inline element?
Block. It creates a space that is effected by element below and above.
How do you indicate the relative link to a parent directory?
parent_dir/file.html
How do you indicate the relative link to a child directory?
/child_dir
How do you indicate the relative link to a grand parent directory?
../dir/file.html
What is the purpose of an HTML form element?
“Input!”
-Number 5 from Shortcircuit
Give five examples of form control elements.
Form, input, select, textarea, button
Give three examples of type attributes for HTML elements.
phone, text. email
Is an HTML element a block element or an inline element?
Inline, because it operates in horizontal space
What are the six primary HTML elements for creating tables?
thead, td, tr, tbody, th, tfoot
What purpose do the thead and tbody elements serve?
thead designates the top of the row for titles.
tbody contains all the data, rows, etc. of table
Give two examples of data that would lend itself well to being displayed in a table.
Financial information.
A restaurant menu.
Name three different types of values you can use to specify colors in CSS.
Names, rbg, hex
What are the names of the individual pieces of a CSS rule?
Selector, property, value
In CSS, how do you select elements by their class attribute?
Placing a period . in front of the selector
In CSS, how do you select elements by their type?
Naming the element
In CSS, how do you select an element by its id attribute?
Placing a # in front of the selector word.
What CSS properties make up the box model?
Margin, padding, border
Which CSS property pushes boxes away from each other?
Margin
Which CSS property add space between a box’s content and its border?
Padding
What is a pseudo-class?
An effect or state that can be added by the browser onto any html element with a colon :
What are CSS pseudo-classes useful for?
Creating an effect or state for an html element when the user gives some kind of input
Name at least two units of type size in CSS.
point and pixels
What CSS property controls the font used for the text inside an element?
font-family
What is the default flex-direction of a flex container?
Horizontally
What is the default flex-wrap of a flex container?
nowrap
Why do two div elements “vertically stack” on one another by default?
They are a block element.
What is the default flex-direction of an element with display: flex?
Horizontally
What is the default value for the position property of HTML elements?
Horizontally
How does setting position: relative on an element affect document flow?
Everything moves around it but it moves.
How does setting position: relative on an element affect where it appears on the page?
It doesn’t. It just floats where ever it boundaries are or relative to the edge of the view port.
How does setting position: absolute on an element affect document flow?
Everything moves around it.
How does setting position: absolute on an element affect where it appears on the page?
It sits where ever css sets it.
How do you constrain an absolutely positioned element to a containing block?
Set the block to position: relative and it will with in those boundaries
What are the four box offset properties?
Relative, fixed, absolute, static.
What is the purpose of variables?
Storing values
How do you declare a variable?
var varName;
How do you initialize (assign a value to) a variable?
var varName = ‘some val’;
What characters are allowed in variable names?
A-Z, a-z, _, &, numbers (not for first character)
What does it mean to say that variable names are “case sensitive”?
A-Z is different from a-z
What is the purpose of a string?
Store array of chars
What is the purpose of a number?
Math!
What is the purpose of a boolean?
true and false values
What does the = operator mean in JavaScript?
Assignment operator
How do you update the value of a variable?
Reassign it
What is the difference between null and undefined?
the former is assign to nothing, the later is not assigned
Why is it a good habit to include “labels” when you log values to the browser console?
Know what the code is doing. Its the only way,
Give five examples of JavaScript primitives.
String, numbers, bool, null, undefined
What data type is returned by an arithmetic operation?
A number
What is string concatenation?
joining strings
What purpose(s) does the + plus operator serve in JavaScript?
Addition and concatenation
What data type is returned by comparing two values (, ===, etc)?
bool
What does the += “plus-equals” operator do?
Adds existing var value to another value
What are objects used for?
Storing data
What are object properties?
Item contained by object
Describe object literal notation.
{}
How do you remove a property from an object?
delete someObj.someProp
What are the two ways to get or update the value of a property?
someObj.someProp
someObj[‘someProp’]
What are arrays used for?
Storing data that has no property
Describe array literal notation.
[]
How are arrays different from “plain” objects?
They have no properties corresponding to values
What number represents the first index of an array?
0
What is the length property of an array?
Returns how many items are in array
How do you calculate the last index of an array?
someArr.length - 1
What is a function in JavaScript?
Repeatable set of instrucitons
Describe the parts of a function definition.
func key word, name, parameters, code block, return statement
Describe the parts of a function call.
Name, arguments.
When comparing them side-by-side, what are the differences between a function call and a function definition?
Making the code, recalling the made code to do something
What is the difference between a parameter and an argument?
Param: template to follow in call, Arg: data put into a call
Why are function parameters useful?
Setting out the kind of data that will go into the called function
Why do we log things to the console?
See what is happening in the code
What is a method?
Built in function callable on appropriate variables
How is a method different from any other function?
Its built in
How do you remove the last element from an array?
.pop
How do you round a number down to the nearest integer?
.floor
How do you generate a random number?
Math.random()
How do you delete an element from an array?
delete arr.someitem
How do you append an element to an array?
arr.push(someItem)
How do you break a string up into an array?
string.split(‘ ‘);
Do string methods change the original string? How would you check if you weren’t sure?
Yes. Console log the string
Roughly how many string methods are there according to the MDN Web docs?
30ish
Is the return value of a function or method useful in every situation?
No
Roughly how many array methods are there according to the MDN Web docs?
30ish
What three-letter acronym should you always include in your Google search about a JavaScript method or CSS property?
mdn
Give 6 examples of comparison operators.
=== == !== < > <= >=
What data type do comparison expressions evaluate to?
bool
What is the purpose of an if statement?
Making decisions
Is else required in order to use an if statement?
no
Describe the syntax (structure) of an if statement.
if(){
}
What are the three logical operators?
&& || !
How do you compare two different expressions in the same condition?
How do you compare two different expressions in the same condition?
What is the purpose of a loop?
Repeating work
What is the purpose of a condition expression in a loop?
See how the loop is repeated
What does “iteration” mean in the context of loops?
The number that counts up to keep track of the loops progress.
When does the condition expression of a while loop get evaluated?
the start
When does the initialization expression of a for loop get evaluated?
var i = 0;
When does the condition expression of a for loop get evaluated?
;i < someVal
When does the final expression of a for loop get evaluated?
;i++)
Besides a return statement, which exits its entire function block, which keyword exits a loop before its condition expression evaluates to false?
break;
What does the ++ increment operator do?
counts up by 1
How do you iterate through the keys of an object?
forEach?
What are the four components of “the Cascade”.
Find all declarations whose selectors match a particular element.
Sort these declarations by weight and origin.
Sort the selectors by specificity.
Sort by order specified.
What does the term “source order” mean with respect to CSS?
Elements lower in the casade will take priority
How is it possible for the styles of an element to be applied to its children as well without an additional CSS rule?
inheritance
List the three selector types in order of increasing specificity.
element selectors, class selectors, id selectors
Why is using !important considered bad practice?
CSS blocks will be difficult to use on other pieces of code.
Why do we log things to the console?
To know what is happening in the code
What is a “model”?
Simplified representation
Which “document” is being referred to in the phrase Document Object Model?
document variable
What is the word “object” referring to in the phrase Document Object Model?
Nodes on the tree
What is a DOM Tree?
Nodes under the document, like <h1> so forth</h1>
Give two examples of document methods that retrieve a single element from the DOM.
.getByID .getByClassSelecotor
Give one example of a document method that retrieves multiple elements from the DOM at once.
querySelectorAll()
Why might you want to assign the return value of a DOM query to a variable?
To access properties later
What console method allows you to inspect the properties of a DOM element object?
console.dir()
Why would a tag need to be placed at the bottom of the HTML content instead of at the top?
To load HTML first
What does document.querySelector() take as its argument and what does it return?
Gets first instance of selector. returns everything between the tags
What does document.querySelectorAll() take as its argument and what does it return?
Gets all elements matching args, returns everything between the tags
Why do we log things to the console?
To know what is going on in the code
What is the purpose of events and event handling?
Make changes dymanically
Are all possible parameters required to use a JavaScript method or function?
No, some are optionsal
What method of element objects lets you set up a function to be called when a specific type of event occurs?
event handleers?
What is a callback function?
Function that happens after an event handler
What object is passed into an event listener callback when the event fires?
event object
What is the event.target? If you weren’t sure, how would you check? Where could you get more information about it?
console.log
What is the difference between these two snippets of code?
element. addEventListener(‘click’, handleClick)
element. addEventListener(‘click’, handleClick())
The first is loading it to be called on the event
The second one is calling the function right ways
What is the className property of element objects?
Renaming class name after selected by querySelector
How do you update the CSS class attribute of an element using JavaScript?
reassign it with className
What is the textContent property of element objects?
Change all the text of an element
How do you update the text within an element using JavaScript?
reassign using textContent
Is the event parameter of an event listener callback always useful?
yes
Would this assignment be simpler or more complicated if we didn’t use a variable to keep track of the number of clicks?
The same
Why is storing information about a program in variables better than only storing it in the DOM?
Querying the dom takes alot of computer power.
What does the transform property do?
Distort an element on x,y, and z axis
Give four examples of CSS transform functions.
scale, rotate, translate, translate
The transition property is shorthand for which four CSS properties?
transition-delay
transition-duration
transition-property
transition-timing-function
What event is fired when a user places their cursor in a form control?
focus
What event is fired when a user’s cursor leaves a form control?
unfocus
What event is fired as a user changes the value of a form control?
input
What event is fired when a user clicks the “submit” button within a ?
submit
What does the event.preventDefault() method do?
prevents the default action is stopped
What does submitting a form without event.preventDefault() do?
Sends data with get
What property of a form element object contains all of the form’s controls.
Elements property
What property of form a control object gets and sets its value?
Naming elements by name
What is one risk of writing a lot of code without checking to see if it works so far?
It not working and having to rewrite it
What is an advantage of having your console open when writing a JavaScript program?
Remembering to test code
Does the document.createElement() method insert a new element into the page?
no
How do you add an element as a child to another element?
.childAppend()
What do you pass as the arguments to the element.setAttribute() method?
arg name of attr, arg value of attr
What steps do you need to take in order to insert a new element into the page?
querySelector() childAppend()
What is the textContent property of an element object for?
Adding text
Name two ways to set the class attribute of a DOM element.
.className = ‘whatEverClass’ .setAttribute()
What are two advantages of defining a function to do create something (like the work of creating a DOM tree)?
Reusablity
Give two examples of media features that you can query in an @media rule.
Screen, braile
Which HTML meta tag is used in mobile-responsive web pages?
viewport meta tag
What is the event.target?
array of element
Why is it possible to listen for events on one element that actually happen its descendent elements?
Using closest()
What DOM element property tells you what type of element it is?
tag make
What does the element.closest() method take as its argument and what does it return?
selector. Returns the dom tree
How can you remove an element from the DOM?
remove()
If you wanted to insert new clickable DOM elements into the page using JavaScript, how could you avoid adding an event listener to every new element individually?
Attach event listener to parent
What is the event.target?
The object of the thing in play
What is the affect of setting an element to display: none?
idk
How can you retrieve the value of an element’s attribute?
.getAttribute(‘’)
At what steps of the solution would it be helpful to log things to the console?
All of them
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?
An event listener for every tab in the exereice. We had 3 tabs and we selected them all.
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?
We had 3 tabs and we selected them all. And edit them in a indivudual code blocks
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?
We had 3 tabs and we selected them all. And edit them in a individual code blocks
What is JSON?
JavaScript Object Notation
What are serialization and deserialization?
Serialized is human readable.
Deserialized is easier to store in the computer
Why are serialization and deserialization useful?
S: means that we can work with the data easily
D: make it easy for the computer work with the data and then shoot it back to us
How do you serialize a data structure into a JSON string using JavaScript?
.stringify()
How do you deserialize a JSON string into a data structure using JavaScript?
.parse()
How to you store data in localStorage?
localStorage.setItem()
How to you retrieve data from localStorage?
localStorage.getItem()
What data type can localStorage save in the browser?
strings, numbers, bool
When does the ‘beforeunload’ event fire on the window object?
Right before refresh.
What is a method?
function attach to a class
How can you tell the difference between a method definition and a method call?
Def: it just sits in the class Call: making it alive
Describe method definition syntax (structure).
Nested in an object
Describe method call syntax (structure).
class.someMethod();
How is a method different from any other function?
its attached to a class instead of free standing
What is the defining characteristic of Object-Oriented Programming?
It attaches action/usefulness to data
What are the four “principles” of Object-Oriented Programming?
Polymorphism, inhertience, abstraction, Encapsulation
What is “abstraction”?
Making the complex simple
What does API stand for?
Application Program Interface
What is the purpose of an API?
Abstracting the systems complexity for simple communication with an outside system
What is this in JavaScript?
place holder
What does it mean to say that this is an “implicit parameter”?
Inserted for another item. Not called outright
When is the value of this determined in a function; call time or definition time?
definition time
How can you tell what the value of this will be for a particular function or method definition?
You can’t
How can you tell what the value of this is for a particular function or method call?
Left of the dot
What kind of inheritance does the JavaScript programming language use?
Prototypical
What is a prototype in JavaScript?
Using existing objects that other ojbects can use as a jumping off point
How is it possible to call methods on strings, arrays, and numbers even though those methods don’t actually exist on objects, arrays, and numbers?
They inherited is from the prototype
If an object does not have it’s own property or method by a given key, where does JavaScript look for it?
Prototype
What does the new operator do?
Creates new instance
What property of JavaScript functions can store shared behavior for instances created with new?
prototypical
What does the instanceof operator do?
tests if var is instance of an object
What is a “callback” function?
It doesn’t have () because it will be called later
Besides adding an event listener callback function to an element or the document, what is one way to delay the execution of a JavaScript function until some point in the future?
setTImeout()
How can you set up a function to be called repeatedly without using a loop?
Set counter outside of function and increment inside function
What is the default time delay if you omit the delay parameter from setTimeout() or setInterval()?
0
What do setTimeout() and setInterval() return?
IntervalId
What is a client?
THe computer
What is a server?
The tthing the computer is sending info to and from
Which HTTP method does a browser issue to a web server when you visit a URL?
get
What three things are on the start-line of an HTTP request message?
Method / Protocol (http) / version 1.1
What three things are on the start-line of an HTTP response message?
Protocol / version / status message (like 404 or 200)
What are HTTP headers?
What are HTTP headers?
All the infos
Where would you go if you wanted to learn more about a specific HTTP Header?
MDN
Is a body required for a valid HTTP request or response message?
No
What is AJAX?
Tool that makes js async and enables api calls
What does the AJAX acronym stand for?
Async Json And Xml
Which object is built into the browser for making HTTP requests in JavaScript?
XMLHttprequest()
What event is fired by XMLHttpRequest objects when they are finished loading the data from the server?
load event
Bonus Question: An XMLHttpRequest object has an addEventListener() method just like DOM elements. How is it possible that they both share this functionality?
Both are branching off of a prototype somewhere up stream
What is a code block? What are some examples of a code block?
Stuff betwee { }
What does block scope mean?
Things only exist inbetween { }
What is the scope of a variable declared with const or let?
Block scope
What is the difference between let and const?
let is mutable, const is immutable.
Why is it possible to .push() a new value into a const variable that points to an Array?
Arrays are mutable over riding the nature of const
How should you decide on which type of declaration to use?
Will the variable need to be reassigned later or how important is it that that var is immutable
What is the syntax for writing a template literal?
` ` (backticks), ${someVar} (variables)
What is “string interpolation”?
Slotting in a var like sometext ${somevar} more text
What is destructuring, conceptually?
making arr and obj into variables
What is the syntax for Object destructuring?
let {var1, var2, var3} = someOjb
What is the syntax for Array destructuring?
let [var1, var2, var3 ] = someArr
How can you tell the difference between destructuring and creating Object/Array literals?
For destructuring the obj/arr has already been created.
What is the syntax for defining an arrow function?
() => {}
When an arrow function’s body is left without curly braces, what changes in its functionality?
that data is returned
How is the value of “this” determined within an arrow function?
At definition time.
What is a CLI?
command line interface
What is a GUI?
graphical user interface
What are the three virtues of a great programmer?
Laziness, impatience, hubris
What is Node.js?
JS on a computer (not a browser)
What can Node.js be used for?
JS on the backend
What is a REPL?
Read Eval Print loop
When was Node.js created?
2009
What back end languages have you heard of?
Python ruby node c c++ c# java php javascript
Perl Lisp Haskell Go Swift Rust Visual-Basic
What back end languages have you heard of?
Python ruby c c++ c# java php javascript
Perl Lisp Haskell Go Swift Rust Visual-Basic
What is a computer process?
Single program running your computer
Roughly how many computer processes are running on your host operating system (Task Manager or Activity Monitor)?
Like at least 100
Why should a full stack Web developer know that computer processes exist?
Because code runs on computers
What is the process object in a Node.js program?
Pulls things from operating system
How do you access the process object in a Node.js program?
global
What is the data type of process.argv in Node.js?
Array of strings
What is a JavaScript module?
A single js file
What values are passed into a Node.js module’s local scope?
exports require module \_\_filename \_\_dirname
What is the purpose of module.exports in a Node.js module?
exporting code to another file
How do you import functionality into a Node.js module from another Node.js module?
require()
What is the JavaScript Event Loop?
Event queue, blocking operations, execute call back,
What is different between “blocking” and “non-blocking” with respect to how code is executed?
blocking is synchronous, non-blocking is asynchronous
Blocking is code currently occupying the call stack
What module does Node.js include for manipulating the file system?
fs
What method is available in the Node.js fs module for writing data to a file?
fs.writeFile()
Are file operations using the fs module synchronous or asynchronous?
both
What is a client?
Initates communication
What is a server?
Send response because it a recieved a request
Which HTTP method does a browser issue to a web server when you visit a URL?
Get
What is on the first line of an HTTP request message?
request methods, destination, version number
What is on the first line of an HTTP response message?
Method version, status code
What are HTTP headers?
Meta information about website
Is a body required for a valid HTTP message?
No
What is NPM?
Node package manager
What is a package?
library to extend functionality
How can you create a package.json with npm?
npm init –yes
What is a dependency and how to you add one to a package?
npm install
What happens when you add a dependency to a package with npm?
It gets added to the package.json
What Express application method starts the server and binds it to a network PORT?
open()
How do you mount a middleware with an Express application?
app.method
Which objects does an Express application pass to your middleware to manage the request/response lifecycle of the server?
req, res
What is the appropriate Content-Type header for HTTP messages that contain JSON in their bodies?
JSON
What is the significance of an HTTP request’s method?
Tells us and the program what is being done.
What is PostgreSQL and what are some alternative relational databases?
MySQL
What are some advantages of learning a relational database?
It works well in a lot of situtations. You can build anything you want and scale projects really big
What is one way to see if PostgreSQL is running?
TOP
What is a database schema?
Tables in a database and how they are organized.
What is a table?
Grouping
What is SQL and how is it different from languages like JavaScript?
No logic
How do you retrieve specific columns from a database table?
select * from someTable
How do you filter rows based on some specific criteria?
..where “someField” = ‘someVal’
What are the benefits of formatting your SQL?
Constient style and readabliity
What are four comparison operators that can be used in a where clause?
= < >
How do you limit the number of rows returned in a result set?
limit 10
What are four comparison operators that can be used in a where clause?
= < > !=
How do you control the sort order of a result set?
… order by “someField” acs limit 10;
What is a foreign key?
id field from table2 in table1
How do you join two SQL tables?
select * from “someTable1”
join “someTable2” using (“someFeildInCommon”)
How do you temporarily rename columns or tables in a SQL statement?
as
How do you delete rows from a database table?
delete “someRow” from “someTable”
How do you accidentally delete all rows from a table?
delete * from “someTable”
How do you update rows in a database table?
update “someRow” from “someTable”
Why is it important to include a where clause in your update statements?
To find exactly where you intend to update
How do you add a row to a SQL table?
insert into “products” (“name”, “description”, “price”, “category”)
values (‘Ostrich Pillow’, ‘Feel comfy and cozy!’, 99, ‘self care’);
What is a tuple?
The values to be inserted
insert into “products” (“name”, “description”, “price”, “category”)
values (‘Ostrich Pillow’, ‘Feel comfy and cozy!’, 99, ‘self care’);
How do you add multiple rows to a SQL table at once?
insert into “products” (“name”, “description”, “price”, “category”)
values (‘Ostrich Pillow’, ‘Feel comfy and cozy!’, 99, ‘self care’),
(‘Tater Mitts’, ‘Scrub some taters!’, 6, ‘cooking’)
returning *;
How do you get back the row being inserted into a table without a separate select statement?
returning *
What are the three states a Promise can be in?
initial, fullfill, reject
How do you handle the fulfillment of a Promise?
.then()
How do you handle the rejection of a Promise?
.catch()
What is Array.prototype.filter useful for?
Getting items without needing a loop
What is “syntactic sugar”?
Makes it easier to read and write
What is the typeof an ES6 class?
Object I think.
Describe ES6 class syntax.
class SomeClass { somePrototypeMethod(){} }
function looks like function SomeFunction{}
SomeFunction.prototype.somePrototypeMethod(){
}
What is “refactoring”?
Changing it to be better. More reliable, readable, etc.
And to get rid of technical debt.
What is Webpack?
It makes files accessible to one another through out the entire.
How do you add a devDependency to a package?
npm install somePackage –save-dev
What is an NPM script?
tells npm what to do like running webpack or a custom script
How do you execute Webpack with npm run?
npm run build
How are ES Modules different from CommonJS modules?
syntax
CommonJS is not part of javascript core.
ES-6 modules are part of the core.
What kind of modules can Webpack support?
Both I think
What is React?
A JS framework for creating webpages and funcitonality quickly
What is a React element?
Created element similar to document.createElement()
How do you mount a React element to the DOM?
ReactDOM.render()
What is Babel?
JS compiler. Converts new JS to old JS
What is a Plug-in?
Adds a specific functionality to extend bigger software
What is a Webpack loader?
Intersects files before they get included in the module
How can you make Babel and Webpack work together?
Babel loader
What is JSX?
JavaScript Extension
Why must the React object be imported when authoring JSX in a module?
Because react tries to stay as lightweight as possible
How can you make Webpack and Babel work together to convert JSX into valid JavaScript?
IDK the build script
What is a React component?
Can be called later with html style element
How do you define a function component in React?
like a variable assigned to JSX
How do you mount a component to the DOM?
Render or just call it
What are props in React?
Properties passed through interitance
How do you pass props to a component?
function SomFunc(props){ }
How do you write JavaScript expressions in JSX?
Fill this in
How do you create “class” component in React?
class SomeCla extends React.Component{ }
How do you access props in a class component?
this.props.some
What Array method is commonly used to create a list of React elements?
.map()
What is the best value to use as a “key” prop when rendering lists?
.Id or number
What does express.static() return?
Files and directories
What is the local __dirname variable in a Node.js module?
Current directory
What does the join() method of Node’s path module do?
Joins strings to browse the file structure
What does fetch() return?
contents of a file
What is the default request method used by fetch()?
get
How do you specify the request method (GET, POST, etc.) when calling fetch?
Method key in the myInit object
When does React call a component’s componentDidMount method?
After render
Name three React.Component lifecycle methods.
render() componentDidMount() componentDidUpdate()
How do you pass data to a child component?
Props like someProps={someInput}