Head First Flashcards
JS Functions: Pass by value or reference
Pass by value
You can find the length of an array using
array.length
Function to generat e uniform random values
Math.random
Function to round to the previous integer
Math.floor
The ____ function can used to trigger a print event from the browser
To write to the console, you use
console.log
How can you delete a property of an object?
By using the delete keyword
Variables can only contain _____ to objects
References
Pass by value applies for objects. But, changing the property of an object in a function changes the property in the original object. Is this true?
Yep
How do you iterate over the properties of an object?
for (var prop in object) { do stuff };
If two objects have different types, then try to convert them to a single type and compare. The ___ operator does this
==
The condition is true iff the two objects have the same type and value. The __ operator does this
===
The following are falsey by default
undefined, null, NaN, ‘’, 0
___ property gives the length of the string
length
The ___ method can be used to index a string
charAt
The ___ method takes a string as an argument and returns the index of the first character of the first occurrence of that argument in the string
indexOf
Give the ____ method two indices, and it will extract and return the string contained within them
substring
The ___ method takes a character that acts as a delimiter, and breaks the string into
parts based on the delimite
split
The ___ method returns a string with all uppercase characters changed to lowercase
toLowerCase
The ___ method finds substrings and replaces them with another string.
replace
The ___ method returns a new string that has part of the original string removed.
slice
The ___ method is like indexOf, but finds the last, not the first, occurrence.
lastIndexOf`
The ___ method joins strings together
concat
The ____ method searches for matches in a
string using regular expressions
match
The ____ method returns a string with all lowercase characters changed to uppercase.
toUpperCase
The ____ method removes whitespace from around the string. Handy when processing user input.
trim
When you want to handle time based events, you call the ____ function and pass it two things. What are those?
setTimeout, event handler function and time period in milliseconds
Get this event
when you click (or
tap) in a web page
click
The event you get when the browser has completed loading a web page.
load
When you move your
mouse over an element,
you’ll generate this event
mousemove
This event is generated
every time you press a key
keypress
This event is generated
when you close the browser
window, or navigate away
from a web page
unload
When you put
your mouse over
an element, you’ll
generate this event
mouseover
And you’ll generate this
event when you move your
mouse off an element.
mouseout
Whenever you resize
your browser window,
this event is generated.
resize
Got in your page?
You’ll get these events when you click the play and pause buttons respectively.
play and pause
If you drag an element
in the page, you’ll
generate this event.
dragstart
On touch devices, you’ll
generate these
events when you touch and
hold an element and stop touching respectively
touchstart and touchend
You’ll get this event when
you drop an element
you’ve been dragging
drop
The _____ constructor is used to create objects
Object
The _____ constructor is used to construct Math objects
Math
Use this constructor to create regular expression objects, which allow you to search for patterns, even complex ones, in text.
Regexp
This constructor creates standard error objects that are handy when catching errors in your code.
Error
You can use the __________ method that every object has. The _______ method returns true if a property is defined in an object instance.
hasOwnProperty
Every prototype chain you create in JavaScript will end in _______
Object
The following properties of Object should not be overridden in any object which inherits from Object
constructor, hasOwnProperty, isPrototypeOf, propertyIsEnumerable