Head First Flashcards

1
Q

JS Functions: Pass by value or reference

A

Pass by value

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

You can find the length of an array using

A

array.length

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

Function to generat e uniform random values

A

Math.random

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

Function to round to the previous integer

A

Math.floor

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

The ____ function can used to trigger a print event from the browser

A

print

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

To write to the console, you use

A

console.log

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

How can you delete a property of an object?

A

By using the delete keyword

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

Variables can only contain _____ to objects

A

References

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

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?

A

Yep

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

How do you iterate over the properties of an object?

A

for (var prop in object) { do stuff };

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

If two objects have different types, then try to convert them to a single type and compare. The ___ operator does this

A

==

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

The condition is true iff the two objects have the same type and value. The __ operator does this

A

===

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

The following are falsey by default

A

undefined, null, NaN, ‘’, 0

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

___ property gives the length of the string

A

length

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

The ___ method can be used to index a string

A

charAt

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

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

A

indexOf

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

Give the ____ method two indices, and it will extract and return the string contained within them

A

substring

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

The ___ method takes a character that acts as a delimiter, and breaks the string into
parts based on the delimite

A

split

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

The ___ method returns a string with all uppercase characters changed to lowercase

A

toLowerCase

20
Q

The ___ method finds substrings and replaces them with another string.

A

replace

21
Q

The ___ method returns a new string that has part of the original string removed.

A

slice

22
Q

The ___ method is like indexOf, but finds the last, not the first, occurrence.

A

lastIndexOf`

23
Q

The ___ method joins strings together

A

concat

24
Q

The ____ method searches for matches in a

string using regular expressions

A

match

25
Q

The ____ method returns a string with all lowercase characters changed to uppercase.

A

toUpperCase

26
Q

The ____ method removes whitespace from around the string. Handy when processing user input.

A

trim

27
Q

When you want to handle time based events, you call the ____ function and pass it two things. What are those?

A

setTimeout, event handler function and time period in milliseconds

28
Q

Get this event
when you click (or
tap) in a web page

A

click

29
Q

The event you get when the browser has completed loading a web page.

A

load

30
Q

When you move your
mouse over an element,
you’ll generate this event

A

mousemove

31
Q

This event is generated

every time you press a key

A

keypress

32
Q

This event is generated
when you close the browser
window, or navigate away
from a web page

A

unload

33
Q

When you put
your mouse over
an element, you’ll
generate this event

A

mouseover

34
Q

And you’ll generate this
event when you move your
mouse off an element.

A

mouseout

35
Q

Whenever you resize
your browser window,
this event is generated.

A

resize

36
Q

Got in your page?

You’ll get these events when you click the play and pause buttons respectively.

A

play and pause

37
Q

If you drag an element
in the page, you’ll
generate this event.

A

dragstart

38
Q

On touch devices, you’ll
generate these
events when you touch and
hold an element and stop touching respectively

A

touchstart and touchend

39
Q

You’ll get this event when
you drop an element
you’ve been dragging

A

drop

40
Q

The _____ constructor is used to create objects

A

Object

41
Q

The _____ constructor is used to construct Math objects

A

Math

42
Q

Use this constructor to create regular expression objects, which allow you to search for patterns, even complex ones, in text.

A

Regexp

43
Q

This constructor creates standard error objects that are handy when catching errors in your code.

A

Error

44
Q

You can use the __________ method that every object has. The _______ method returns true if a property is defined in an object instance.

A

hasOwnProperty

45
Q

Every prototype chain you create in JavaScript will end in _______

A

Object

46
Q

The following properties of Object should not be overridden in any object which inherits from Object

A

constructor, hasOwnProperty, isPrototypeOf, propertyIsEnumerable