JavaScript Flashcards

1
Q

JAVASCRIPT-PRIMITIVES-AND-VARIABLES

What is the purpose of variables?

A

Variables are used to store data for the computers to use in the future
For the future;

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

JAVASCRIPT-PRIMITIVES-AND-VARIABLES

How do you declare a variable?

A

use a keyword (var, let, const) and variable name and =

Example: var example = 100;

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

JAVASCRIPT-PRIMITIVES-AND-VARIABLES

How do you initialize (assign a value to) a variable?

A

use an equal sign

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

JAVASCRIPT-PRIMITIVES-AND-VARIABLES

What characters are allowed in variable names?

A

letter, numbers, $, underscore,

numbers cant be first

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

JAVASCRIPT-PRIMITIVES-AND-VARIABLES

What does it mean to say that variable names are “case sensitive”?

A

Car= and car= are different variables

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

JAVASCRIPT-PRIMITIVES-AND-VARIABLES

What is the purpose of a string?

A

for storing text that wouldn’t make sense to JavaScript

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

JAVASCRIPT-PRIMITIVES-AND-VARIABLES

What is the purpose of a number?

A

For doing calculations;

If the number is a zipcode then store as string;

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

JAVASCRIPT-PRIMITIVES-AND-VARIABLES

What is the purpose of a boolean?

A

it is for letting computers make a decision that is true or false;
to make decisions

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

JAVASCRIPT-PRIMITIVES-AND-VARIABLES

What does the = operator mean in JavaScript?

A

assignment operator

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

JAVASCRIPT-PRIMITIVES-AND-VARIABLES

How do you update the value of a variable?

A

Update the value of a variable by assigning a new value to the variable name without the keyword

Example:
let a = 2; for declaring a variable
a = 5; for updating a variable (no need for keyword)
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q

JAVASCRIPT-PRIMITIVES-AND-VARIABLES

What is the difference between null and undefined?

A
  • null is absents of value intentionally
    (ex: optional user input)
  • undefined is not trustworthy
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
12
Q

JAVASCRIPT-PRIMITIVES-AND-VARIABLES

Why is it a good habit to include “labels” when you log values to the browser console?

A

Label within the console.log to know where you’re getting values from / for organization purposes
(especially when going back to the code)

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
13
Q

JAVASCRIPT-PRIMITIVES-AND-VARIABLES

Give five examples of JavaScript primitives.

A

string, number, boolean, null, and undefined

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
14
Q

JAVASCRIPT-OPERATORS-AND-EXPRESSIONS

What data type is returned by an arithmetic operation?

A

numeric data

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
15
Q

JAVASCRIPT-OPERATORS-AND-EXPRESSIONS

What is string concatenation?

A

Process of joining together two or more strings to create one new string

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
16
Q
JAVASCRIPT-OPERATORS-AND-EXPRESSIONS
What purpose(s) does the + plus operator serve in JavaScript?
A

adds one value to another;

addition of numbers and concatenation of strings

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
17
Q

JAVASCRIPT-OPERATORS-AND-EXPRESSIONS
What data type is returned by comparing two values
(>, ===, < etc)?

A

booleans (true or false)

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
18
Q

JAVASCRIPT-OPERATORS-AND-EXPRESSIONS

What does the += “plus-equals” operator do?

A

left operand = left operand + right operand

Example: 2 += 3 = 5

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
19
Q

JAVASCRIPT-OBJECTS

What are objects used for?

A

objects {} are used group together a set of variables and functions to create a model / representation of something

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
20
Q

JAVASCRIPT-OBJECTS

What are object properties?

A

properties tell us about the object;
the variable of an object;

Example: name, age, etc.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
21
Q

JAVASCRIPT-OBJECTS

Describe object literal notation.

A

Store object in variable, within opening and closing curly braces are properties and their values;

Example: 
var object = { properties: value }
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
22
Q

JAVASCRIPT-OBJECTS

How do you remove a property from an object?

A

Use delete operator
Example:
delete object.property or delete object[‘property’]

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
23
Q

JAVASCRIPT-OBJECTS

What are the two ways to get or update the value of a property?

A

dot notation or bracket notation

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
24
Q

JAVASCRIPT-ARRAYS

What are arrays used for?

A

Array are used for storing values in a grouped list like a grocery list where orders are not essential;

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
25
JAVASCRIPT-ARRAYS | Describe array literal notation.
var array = [ ];
26
JAVASCRIPT-ARRAYS | How are arrays different from "plain" objects?
Objects have individual assigned properties but arrays have automatic number indexes assigned Within array you know how many pieces of data being stored (length property) To add data to an array, use method (push); To add data to object, use dot / bracket notation
27
JAVASCRIPT-ARRAYS | What number represents the first index of an array?
0 / Zero
28
JAVASCRIPT-ARRAYS | What is the length property of an array?
The length property is used to find the length of an array
29
JAVASCRIPT-ARRAYS | How do you calculate the last index of an array?
array.length - 1
30
JAVASCRIPT-FUNCTION | What is a function in JavaScript?
a reusable block of code | includes a set of instructions
31
JAVASCRIPT-FUNCTION | Describe the parts of a function definition.
keyword, optional name, optional number of parameters, code block, return
32
JAVASCRIPT-FUNCTION | Describe the parts of a function call.
name, ( ), and arguments
33
JAVASCRIPT-FUNCTION | When comparing them side-by-side, what are the differences between a function call and a function definition?
function call doesn't have keyword function and uses ( ) to call the function function definition has the code block and function keyword
34
JAVASCRIPT-FUNCTION | What is the difference between a parameter and an argument?
``` parameter = placeholder for potential value; argument = actual value being placed in the argument; ```
35
JAVASCRIPT-FUNCTION | Why are function parameters useful?
Function parameters are useful because they pass information to a function in order to be able to reuse the function code block Without parameters, function always does the same thing With parameters, we can input different values and get different results
36
JAVASCRIPT-FUNCTION | What two effects does a return statement have on the behavior of a function?
1. Causes the function to produce a value we can use in our program. 2. Prevents any more code in the function's code block from being run. ``` 1. Will replace the function called in that line of code; Example: function(3) = 10 var x = function(3) ... will become var x = 10 ``` 2. Stops the function entirely once a value is returned
37
JAVASCRIPT-METHODS | Why do we log things to the console?
to debug our code, to check if our output is as expected, etc.
38
JAVASCRIPT-METHODS | What is a method?
function that is a property of an object
39
JAVASCRIPT-METHODS | How is a method different from any other function?
methods have to be called on an object; | functions do not;
40
JAVASCRIPT-METHODS | How do you remove the last element from an array?
pop( ) pop method
41
JAVASCRIPT-METHODS | How do you round a number down to the nearest integer?
Math.floor( )
42
JAVASCRIPT-METHODS | How do you generate a random number?
Math.random( ) | 0 < 1
43
JAVASCRIPT-METHODS | How do you delete an element from an array?
pop for last item; shift for first item; splice for specific index
44
JAVASCRIPT-METHODS | How do you append (to the end) an element to an array?
push( ) Push method
45
JAVASCRIPT-METHODS | How do you break a string up into an array?
split(' ') Split method
46
JAVASCRIPT-METHODS | Do string methods change the original string? How would you check if you weren't sure?
does not change the original string; | To check: console.log( )
47
JAVASCRIPT-METHODS | Roughly how many string methods are there according to the MDN Web docs?
About 50
48
JAVASCRIPT-METHODS | Is the return value of a function or method useful in every situation?
No, not in every situation
49
JAVASCRIPT-METHODS | Roughly how many array methods are there according to the MDN Web docs?
A lot
50
JAVASCRIPT-METHODS | What three-letter acronym should you always include in your Google search about a JavaScript method or CSS property?
MDN | which stands for: Mozilla Developer Network
51
JAVASCRIPT-IF | Give 6 examples of comparison operators.
``` == is equal to; != is not equal to; === is strictly equal to; !== is strictly not equal to; > is greater than; < is less than; >= is greater than or equal to; <= is less than or equal to; ```
52
JAVASCRIPT-IF | What data type do comparison expressions evaluate to?
Boolean (true or false)
53
JAVASCRIPT-IF | What is the purpose of an if statement?
An if statement evaluates (or checks) a condition. | Let the computer make a decision based on conditions.
54
JAVASCRIPT-IF | Is else required in order to use an if statement?
no, only if you want to provide more than one set of code / another execution
55
JAVASCRIPT-IF | Describe the syntax (structure) of an if statement.
if (condition)... conditional code block | instruction: { } else { }
56
JAVASCRIPT-IF | What are the three logical operators?
&& (and) ; || (or); ! (not);
57
JAVASCRIPT-IF | How do you compare two different expressions in the same condition?
&& (and); | || (or);
58
JAVASCRIPT-LOOPS | What is the purpose of a loop?
To continuously iterate through a code block until the condition is met Allows us to repeat a certain function
59
JAVASCRIPT-LOOPS | What is the purpose of a condition expression in a loop?
To know when to stop the loop
60
JAVASCRIPT-LOOPS | What does "iteration" mean in the context of loops?
Iteration = looping through once
61
JAVASCRIPT-LOOPS | When does the condition expression of a while loop get evaluated?
At the start of every loop
62
JAVASCRIPT-LOOPS | When does the initialization expression of a for loop get evaluated?
Before the loop begins and only once
63
JAVASCRIPT-LOOPS | When does the condition expression of a for loop get evaluated?
Before each iteration
64
JAVASCRIPT-LOOPS | When does the final expression of a for loop get evaluated?
After each iteration | Before condition runs again
65
JAVASCRIPT-LOOPS Besides a return statement, which exits its entire function block, which keyword exits a loop before its condition expression evaluates to false?
Break
66
JAVASCRIPT-LOOPS | What does the ++ increment operator do?
increments by 1
67
JAVASCRIPT-LOOPS | How do you iterate through the keys of an object?
For in loop
68
DOM-QUERYING | Why do we log things to the console?
To see what we're doing and for debugging
69
DOM-QUERYING | What is a "model"?
representation of something
70
DOM-QUERYING | Which "document" is being referred to in the phrase Document Object Model?
the html document
71
DOM-QUERYING | What is the word "object" referring to in the phrase Document Object Model?
object is a data type | A javascript object modeling the html document's content.
72
DOM-QUERYING | What is a DOM Tree?
organization of/chunk of document representative chunk of the page that shows the element and their element's configuration DOM = model that represents an html document in the form of javascript data types all of the information necessary to create the content
73
DOM-QUERYING | Give two examples of document methods that retrieve a single element from the DOM.
document. querySelector( ); | document. getElementById( );
74
DOM-QUERYING | Give one example of a document method that retrieves multiple elements from the DOM at once.
document.querySelectorAll( )
75
DOM-QUERYING | Why might you want to assign the return value of a DOM query to a variable?
to be able to use it again in the future
76
DOM-QUERYING | What console method allows you to inspect the properties of a DOM element object?
console.dir( ) Console.dir( ) is the way to see all the properties of a specified JavaScript object in console by which the developer can easily get the properties of the object.
77
DOM-QUERYING | Why would a tag need to be placed at the bottom of the HTML content instead of at the top?
HTML loads from top to bottom and the elements need to load first
78
DOM-QUERYING | What does document.querySelector() take as its argument and what does it return?
The document.querySelector( ) takes a css selector as an argument and returns first one that matches
79
DOM-QUERYING | What does document.querySelectorAll( ) take as its argument and what does it return?
The document.querySelectorAll( ) takes a css selector as an argument and returns a NodeList
80
DOM-EVENTS | Why do we log things to the console?
In this exercise... | to debug and check if action happened
81
DOM-EVENTS | What is the purpose of events and event handling?
when user does something, another thing happens - something that happens - to set up a list of action whenever an event occurs interactivity (event handling)
82
DOM-EVENTS | Are all possible parameters required to use a JavaScript method or function?
no they are not; | 3rd parameter of addEventListener is optional
83
DOM-EVENTS | What method of element objects lets you set up a function to be called when a specific type of event occurs?
addEventListener( )
84
DOM-EVENTS | What is a callback function?
a function that is called as an argument in another function
85
DOM-EVENTS | What object is passed into an event listener callback when the event fires?
an object that is built in the moment as a reference of data all relevant data is created, therefore you could get specific information in that one specific occurrence
86
DOM-EVENTS | What is the event.target? If you weren't sure, how would you check? Where could you get more information about it?
the button that you interact with; target = the dom element where the event originated from; If you weren't sure, then console.log(event.target); You could get more information about it in MDN
87
DOM-EVENTS What is the difference between these two snippets of code? element.addEventListener('click', handleClick) element.addEventListener('click', handleClick( ) )
2nd one is an anonymous function which may result in undefined. - Always gets called without having to click it
88
DOM-MANIPULATION | What is the className property of element objects?
Property that can get or set the value of class attribute
89
``` DOM-MANIPULATION How do you update the CSS class attribute of an element using JavaScript? ```
Use the className property on an element; select your element.className = new value;
90
DOM-MANIPULATION | What is the textContent property of element objects?
to get or set a text element
91
DOM-MANIPULATION | How do you update the text within an element using JavaScript?
select your element.textContent = 'sample'
92
DOM-MANIPULATION | Is the event parameter of an event listener callback always useful?
No, if it's not necessary, then no need.
93
DOM-MANIPULATION | Would this assignment be simpler or more complicated if we didn't use a variable to keep track of the number of clicks?
More complicated if we did not have variable
94
DOM-MANIPULATION | Why is storing information about a program in variables better than only storing it in the DOM?
Makes it easier to know what's going on in your own code. Store it in Javascript in variables and use that data to influence the DOM. Its better to use data within the same language that you are working within.
95
JAVASCRIPT-FORMS | What event is fired when a user places their cursor in a form control?
focus event
96
JAVASCRIPT-FORMS | What event is fired when a user's cursor leaves a form control?
blur event
97
JAVASCRIPT-FORMS | What event is fired as a user changes the value of a form control?
input event
98
JAVASCRIPT-FORMS | What event is fired when a user clicks the "submit" button within a form?
submit
99
JAVASCRIPT-FORMS | What does the event.preventDefault() method do?
Stops the default behavior from happening | In this exercise... stop browser from refreshing
100
JAVASCRIPT-FORMS | What does submitting a form without event.preventDefault() do?
Refreshes the page; Changes URL; B/c of the action attribute (outdated)
101
JAVASCRIPT-FORMS | What property of a form element object contains all of the form's controls?
elements property
102
JAVASCRIPT-FORMS | What property of a form control object gets and sets its value?
value
103
JAVASCRIPT-FORMS | What is one risk of writing a lot of code without checking to see if it works so far?
Realizing it does not work
104
JAVASCRIPT-FORMS | What is an advantage of having your console open when writing a JavaScript program?
Can check to see if your code works as you're working on it
105
DOM-CREATION | Does the document.createElement() method insert a new element into the page?
No, just creates a node; | You would still have to append it;
106
DOM-CREATION | How do you add an element as a child to another element?
appendChild( ) method
107
DOM-CREATION | What do you pass as the arguments to the element.setAttribute( ) method?
pass two stings; | setAttribute ( name of attribute, value we wanna set attribute to);
108
DOM-CREATION | What steps do you need to take in order to insert a new element into the page?
create an element, querySelect for parent, generate child element Example: var h1 = document.createElement('h1') someDiv.appendChild(h1)
109
DOM-CREATION | What is the textContent property of an element object for?
To append text to a node and for looking at current text / to get or set text content You can also check the text with textContent
110
``` DOM-CREATION Name two ways to set the class attribute of a DOM element. ```
setAttribute( ); Example: setAttribute('className', 'classValues') class.Name; Example: element.className = 'class'
111
DOM-CREATION | What are two advantages of defining a function to create something (like the work of creating a DOM tree)?
- saves a lot of time | - makes it reusable
112
DOM-EVENT-DELEGATION | What is the event.target?
event.target is | where the event originated from
113
DOM-EVENT-DELEGATION | Why is it possible to listen for events on one element that actually happen its descendent elements?
event bubbling
114
DOM-EVENT-DELEGATION | What DOM element property tells you what type of element it is?
event.target.tagName
115
DOM-EVENT-DELEGATION | What does the element.closest() method take as its argument and what does it return?
The element.closest( ) method take as its argument... a CSS selector; It matches it with closest ancestor (parent) element
116
DOM-EVENT-DELEGATION | How can you remove an element from the DOM?
call the remove method on the element we want removed element.remove( )
117
DOM-EVENT-DELEGATION 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?
addEventListener to the parent element; | use tagName method to check if you're targeting the right element;
118
JAVASCRIPT-VIEW-SWAPPING | What is the event.target?
Where the event originated from
119
JAVASCRIPT-VIEW-SWAPPING | What is the affect of setting an element to display: none?
It will hide the element from the viewer
120
JAVASCRIPT-VIEW-SWAPPING | What does the element.matches() method take as an argument and what does it return?
``` The element.matches ( ) takes as an argument... css selectors and returns a boolean value ```
121
JAVASCRIPT-VIEW-SWAPPING | How can you retrieve the value of an element's attribute?
In order to retrieve the value of an element's attribute, | call it on the DOM element
122
JAVASCRIPT-VIEW-SWAPPING | At what steps of the solution would it be helpful to log things to the console?
Every Step
123
JAVASCRIPT-VIEW-SWAPPING 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 add an event listener for each individual element
124
JAVASCRIPT-VIEW-SWAPPING 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 would have to write many conditional statements
125
JAVASCRIPT-AND-JSON | What is JSON?
JavaScript Object Notation (JSON) is a standard text-based format for representing structured data based on JavaScript object syntax. It is commonly used for transmitting data in web applications (e.g., sending some data from the server to the client, so it can be displayed on a web page, or vice versa). In summary; JavaScript Object Notation and lets us store them that is not in memory space
126
JAVASCRIPT-AND-JSON | What are serialization and deserialization?
Converting a native object to a string so it can be transmitted across the network is called serialization; Converting a string to a native object to be able to transmit is called deserialization - bringing back complexity of how data is stored for access Think of packing for a trip... metaphor
127
JAVASCRIPT-AND-JSON | Why are serialization and deserialization useful?
JSON exists as a string — useful when you want to transmit data across a network. It needs to be converted to a native JavaScript object when you want to access the data. Breaks down data to byte size and easy to transmit data and load data throughout the web and store data
128
JAVASCRIPT-AND-JSON | How do you serialize a data structure into a JSON string using JavaScript?
JSON.stringify( )
129
JAVASCRIPT-AND-JSON | How do you deserialize a JSON string into a data structure using JavaScript?
JSON.parse( )
130
JAVASCRIPT-LOCAL-STORAGE | How do you store data in localStorage?
localStorage.setItem( keyName , keyValue )
131
JAVASCRIPT-LOCAL-STORAGE | How do you retrieve data from localStorage?
localStorage.getItem( keyName )
132
JAVASCRIPT-LOCAL-STORAGE | What data type can localStorage save in the browser?
Strings
133
JAVASCRIPT-LOCAL-STORAGE | When does the 'beforeunload' event fire on the window object?
It is fired when the window, the document, and its resources are about to be unloaded.
134
JAVASCRIPT-CUSTOM-METHODS | What is a method?
A method is a function stored within a property of an object. Two kinds: Instance Methods - built-in tasks performed by an object instance;' Static Methods - tasks that are called directly on an object;
135
JAVASCRIPT-CUSTOM-METHODS | How can you tell the difference between a method definition and a method call?
Method call is conceptualized as a message (the name of the method and its input parameters) being passed to the object for dispatch. Method definition is conceptualized as the shorthand for a function assigned to the method's name.
136
JAVASCRIPT-CUSTOM-METHODS | Describe method definition syntax (structure).
``` The method definition syntax (structure) may include: var object = { Property: function (anonymous or named) (parameters) { steps of the function } }; ```
137
JAVASCRIPT-CUSTOM-METHODS | Describe method call syntax (structure).
The method call syntax (structure) may include: The name of the method and its input parameters Example: - name of object. name of method(parameter)
138
JAVASCRIPT-CUSTOM-METHODS | How is a method different from any other function?
A method, like a function, is a set of instructions that perform a task. The difference is that a method is associated with an object, while a function is not.
139
JAVASCRIPT-CUSTOM-METHODS | What is the defining characteristic of Object-Oriented Programming?
The defining characteristic of Object-Oriented Programming is: objects can contain both data (as properties) and behavior (as methods).
140
JAVASCRIPT-CUSTOM-METHODS | What are the four "principles" of Object-Oriented Programming?
``` Four "principles" of Object-Oriented Programming: Abstraction, Encapsulation, Inheritance, Polymorphism ```
141
JAVASCRIPT-CUSTOM-METHODS | What is "abstraction"?
An "abstraction" is a way to interact with a system in a simplified, consistent fashion. Involves the usage of data types, modeling and usage of procedures, functions, or subroutines which represent a specific of implementing control flow in programs. - Control Flow: is the order in which individual statements, instructions or function calls of an imperative program are executed or evaluated
142
JAVASCRIPT-CUSTOM-METHODS | What does API stand for?
Application Programming Interface (API) | - connection between computers or between computer programs
143
JAVASCRIPT-CUSTOM-METHODS | What is the purpose of an API?
The purpose of software API is to give programmers a way to interact with a system (and functionality) in a simplified, consistent fashion. Involves connection between computers or between computer programs. One purpose of APIs is to hide the internal details of how a system works, exposing only those parts a programmer will find useful and keeping them consistent even if the internal details later change.
144
JAVASCRIPT-THIS | What is this in JavaScript?
The object you're working with currently. A variable whose value is the object you're currently working with.
145
JAVASCRIPT-THIS | What does it mean to say that this is an "implicit parameter"?
Can use even though it is not explicitly declared in the function (present but not directly stated).
146
JAVASCRIPT-THIS | When is the value of this determined in a function; call time or definition time?
Call time
147
JAVASCRIPT-THIS | What does this refer to in the following code snippet?
this means nothing.. because it was never called
148
JAVASCRIPT-THIS | Given the above character object, what is the result of the following code snippet? Why?
"It's a-me, Mario"
149
JAVASCRIPT-THIS | Given the above character object, what is the result of the following code snippet? Why?
"It's a-me, undefined"
150
JAVASCRIPT-THIS | How can you tell what the value of this will be for a particular function or method definition?
We don't know.... because it is in definition time / placeholder
151
JAVASCRIPT-THIS | How can you tell what the value of this is be for a particular function or method call?
the object to the left of the dot
152
JAVASCRIPT-PROTOTYPES | What kind of inheritance does the JavaScript programming language use?
JavaScript includes a specific kind of inheritance known as prototype-based (or prototypal) inheritance where JavaScript objects give certain behaviors (methods) or data (properties) to other objects.
153
JAVASCRIPT-PROTOTYPES | What is a prototype in JavaScript?
Prototypes are the mechanism by which JavaScript objects inherit features from one another. Data and behavior in one spot and all things can consider that data to hold the same behavior.
154
JAVASCRIPT-PROTOTYPES How is it possible to call methods on strings, arrays, and numbers even though those methods don't actually exist on strings, arrays, and numbers?
Through inheritance
155
JAVASCRIPT-PROTOTYPES | If an object does not have its own property or method by a given key, where does JavaScript look for it?
in the prototype | where the shared behavior is stored...
156
JAVASCRIPT-CONSTRUCTORS | What does the new operator do?
The new operator lets developers create an instance of a user-defined object type or of one of the built-in object types that has a constructor function. - creates a new blank object - points to prototype of the function that made it - this becomes whatever object that was just made - returns that object if no other return is specified (which there shouldn't be one)
157
JAVASCRIPT-CONSTRUCTORS | What property of JavaScript functions can store shared behavior for instances created with new?
Prototype property | stores an object and object holds shared data and behavior
158
JAVASCRIPT-CONSTRUCTORS | What does the instanceof operator do?
The instanceof operator tests to see if the prototype property of a constructor appears anywhere in the prototype chain of an object. The return value is a boolean value. - left being variable (whatever you want to check / object class) and right being what you want to check the instance of
159
JAVASCRIPT-TIMERS | What is a "callback" function?
A callback function is a function passed into another function as an argument, which is then invoked inside the outer function to complete some kind of routine or action.
160
JAVASCRIPT-TIMERS 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?
setTimout( ) method | - method sets a timer which executes a function or specified piece of code once the timer expires
161
JAVASCRIPT-TIMERS | How can you set up a function to be called repeatedly without using a loop?
setInterval( ) - method, offered on the Window and Worker interfaces, repeatedly calls a function or executes a code snippet, with a fixed time delay between each call
162
JAVASCRIPT-TIMERS | What is the default time delay if you omit the delay parameter from setTimeout() or setInterval()?
If delay parameter is omitted, a value of 0 is used, meaning execute "immediately", or more accurately, the next event cycle. If nothing else needs to be done, it will happen immediately
163
JAVASCRIPT-TIMERS | What do setTimeout() and setInterval() return?
The returned timeoutID is a positive integer value which identifies the timer created by the call to setTimeout( ); this value can be passed to clearTimeout() to cancel the timeout. The returned intervalID is a numeric, non-zero value which identifies the timer created by the call to setInterval(); this value can be passed to clearInterval() to cancel the interval.
164
JAVASCRIPT-AJAX | What is AJAX?
AJAX is a technique for loading data into part of a page without having to refresh the entire page.
165
JAVASCRIPT-AJAX | What does the AJAX acronym stand for?
Asynchronous Javascript And XML
166
JAVASCRIPT-AJAX | Which object is built into the browser for making HTTP requests in JavaScript?
XMLHttpRequest Browsers implement an object called XMLHttpRequest to handle Ajax requests. Once a request has been made, the browser does not wait for a response from the server.
167
JAVASCRIPT-AJAX | What event is fired by XMLHttpRequest objects when they are finished loading the data from the server?
load - When the server has finished responding to the request, the browser will fire an event (just like it can fire an event when a page has finished loading). This event can be used to trigger a JavaScript function that will process the data and incorporate it into one part of the page (without affecting the rest of the page).
168
JAVASCRIPT-AJAX An XMLHttpRequest object has an addEventListener() method just like DOM elements. How is it possible that they both share this functionality?
prototypal inheritance