JAVASCRIPT Flashcards

1
Q

Who originally developed JS?

A

Branden Eich.

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

What was JS originally called?

A

LiveScript

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

When was JS named JS? Why then?

A

LiveScript was renamed JavaScript in 1995, as it became a joint venture of Netscape and Sun.

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

Who standardized JS as ECMA-262?

A

The European Computer Manufacturers Association.

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

Is JS statically or dynamically typed?

A

Dynamically.

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

JS is solely a client side language.

A

False - it may be used server side as well.

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

Is JS case sensitive?

A

Yes.

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

What’s a synonym for dynamic typing?

A

Loose typing.

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

What is the root object in JS?

A

Object

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

What type of inheritance does JS exhibit?

A

Prototypal inheritance.

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

Is there polymorphism in JS?

A

No.

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

A web server is needed for JS.

A

False.

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

Write the html to import an external script.js file.

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

How can JS code be embedded into html?

A
<script>
...
</script>
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
15
Q

What are the ways to write comments in JS?

A

// …
/* … */

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

What JS object provides functions such as floor, round, max, min, etc?

A

Math

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

What are the 5 JS primitive types?

A

Number, String, Boolean, Undefined and Null.

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

Do the null type and the undefined type have several possible values?

A

No.

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

What is returned by an arithmetic operation that creates overflow?

A

NaN

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

What does (NaN == NaN) return?

A

False.

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

How should you check for NaN values?

A

isNaN(x)

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

What are the 4 ways of declaring a JS variable?

A

using var, let, const, or using nothing.

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

What operator coerces strings into numbers, and numbers into strings depending on the context?

A

+

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

List 2 ways of explicitly converting a number into a string.

A

Using the String constructor, or using a number’s toString() method.

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

List 2 ways of explicitly converting a string to a number.

A

Using the Number constructor, or using parseInt() / parseFloat() functions.

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

What does the following print?
console.log(1 + 2 + “bird”);

A

3bird

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

When does the + operator execute numeric addition, rather than concatenation?

A

Only when both operands are numbers.

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

What is the result of ‘$’ + 3 + 4 ?

A

$34
(left to right execution)

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

When does < or > execute a number comparison?

A

When both operands are numbers, or if one is a number and the other can be converted to a number.

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

When is the result of a < or > comparison always false?

A

When one operand is a number, the other isn’t and can’t be converted to a number.

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

What is the result of “11” < “2”?

A

True, because a string comparison is performed if both operands are strings.

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

What is the result of the following?
11 < 2+ “birds”

A

False, since the RHS becomes “2birds” which can’t be converted to a number in JS.

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

What is the result of the following?
‘$’ + 3 < 4

A

False - can’t convert ‘$3’ to a number.

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

When is * a number multiply?

A

If both operands are numbers, or both can be converted to a
number.

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

What is the result of a multiplication (*) wherein one of the operands cannot be converted to a number?

A

NaN

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

What is the result of the following?
‘$’*3 < 4

A

False.

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

Is there a character type in JS?

A

No.

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

How many bits are each character in a JS string?

A

16

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

How can characters be represented in JS?

A

As strings with a length of 1.

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

Are strings immutable in JS?

A

Yes.

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

The == operator can be used to check for value equality between 2 strings in JS.

A

True.

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

Do string literals use single or double quotes in JS?

A

Either.

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

How can you obtain the length of a string object?

A

str.length

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

What is the difference between ‘String(val)’ and new ‘String(val)’ ?

A

String(val) returns a string,
new String(val) returns an object.

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

What does the following code print?
var a = “123”;
var b = “123”;
document.write(a==b);

A

true

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

What method can return the character at a specified index, x, of a string, str?

A

str.charAt(x)

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

What method (not operator) can join two strings, s1 & s2, into a single string?

A

s1.concat(s2)

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

What method returns the index position of some character/substring str2 within str1?

A

str1.indexOf(str2)

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

What method returns the index position of some character/substring str2 within str1, and searches right to left?

A

str1.lastIndexOf(str2)

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

What method compiles all instances of a string (or regex), x, found within a string str, into an array it then returns?

A

str.match(x)

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

What method can replace all instances of str2 with str3, within str1?

A

str1.replace(str2, str3)

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

Does .replace() change the original string?

A

No, it returns a new one with the changes made.

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

What does the str.search(x) method do?

A

It returns the index (position) of the first match of x within str.

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

What does .search() return if no matches are found?

A

.search() returns -1.

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

What JS method returns a substring of str, between indices i1 and up to (but not including) i2?

A

str.slice(i1, i2)

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

What does str.split(“,”) do?

A

It splits str at its commas and returns an array of the resulting substrings.

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

What method behaves almost exactly str.slice(i1, i2)?

A

.substring()

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

Do the JS methods str.toUpperCase() and str.toLowerCase() put all characters of str to upper/lower case, or only the first?

A

All.

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

In JS, what non-Boolean equate to Boolean false? (6)

A

0, -0, “”, NaN, undefined, null.

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

In JS, “0” equates to what Boolean value?

A

True.

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

How can you explicitly convert a non Boolean to a Boolean value?

A

Boolean(val)

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

What does the following return?
Boolean(“false”);

A

true

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

What does the JS Date object’s .getTime() method return?

A

The number of milliseconds since January 1, 1970.

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

What JS object represents the model for the browser’s display window?

A

The Window object.

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

What’s the difference between the JS alert(msg) and confirm(msg) functions?

A

The confirm popup has an additional “cancel” button.

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

What does the JS prompt() function do?

A

Creates a popup window capable of accepting input.

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

What is the purpose of the optional second parameter of the prompt() method?

A

The optional second parameter specifies the default text within the input section of the popup.

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

What’s the difference between == / != and === / !== ?

A

=== / !== don’t do type coercion.

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

what does “123” == “123” return?

A

true

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

What does (3 !== “3”) return?

A

true

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

What is the output of the following?
var a = new String(“123”);
var b = new String(“123”);
document.write(a==b);

A

false, due to the (double) use of the new operator.

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

What is the output of the following?
var a = String(“123”);
var b = new String(“123”);
document.write(a==b);

A

true

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

&& and || always return Boolean values.

A

False - && returns the second operand if the first is truthy (else it returns the first) and || returns the first operand if it is truthy (else it returns the second).

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

! always returns a Boolean value.

A

True.

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

Explicitly convert a value to true or false without using Boolean(val).

A

!!val

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

How many bitwise operators are there in JS? List them.

A

6 - &, |, ~, ^, «,&raquo_space;

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

What does the & operator do?

A

& ANDs the binary representations of its operands.

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

What does the | operator do?

A

It ORs the binary representations of its operands.

ORs

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

What does the ~ operator do?

A

It negates (flips) the binary representation of its operand.

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

What does the ^ operator do?

A

It XORs the binary representations of its operands.

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

What does the &laquo_space;operator do?

A

It bit-shifts the binary representation of its first operand by n bits to the left, where n is the second operand.

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

What does the&raquo_space; operator do?

A

It bit-shifts the binary representation of its first operand by n bits to the right, where n is the second operand.

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

The default case must be the last case in a JS switch block.

A

False.

84
Q

Along with while and for loops, do-while loops also exist in JS.

A

True.

85
Q

When was the let keyword introduced?

A

In 2015.

86
Q

Can variables defined with let be redeclared?

A

No.

87
Q

Can variables defined with let be used before declaration?

A

No.

88
Q

What is the scope of a variable defined with let?

A

Variables defined with let have block scope.

89
Q

Can variables defined with var be redeclared?

A

Yes.

90
Q

Can variables defined with var be used before declaration?

A

Yes.

91
Q

What is the scope of variables defined with const?

A

Variables defined with const have block scope.

92
Q

What is the scope of variables declared with var?

A

Either the enclosing function and functions declared within it, or global if declared outside any function.

93
Q

Variables with const cannot be redefined, but they can be redeclared.

A

False - they also can’t be redeclared.

94
Q

What is the scope of variables defined with const?

A

Variables defined with const have block scope.

95
Q

What is the output of the following code?
var name = “APPLE”;
{ var name = “BANANA”;
console.log(name); }
console.log(name);

A

BANANA
APPLE

96
Q

What will be the value of a variable used prior to declaration?

A

Undefined.

97
Q

What will happen if I remove the second line?
alert(“0-“+scope);
var scope = “global”;

A

An error is produced.

98
Q

What will be the output of the following?
console.log(x);
var x = “APPLE”;
function checkloc() {
console.log(x);
var x;
}
checkloc();

A

undefined
undefined

99
Q

What will be the output of the following?
console.log(x);
var x = “APPLE”;
function checkloc() {
var x;
console.log(x);
}
checkloc();

A

undefined
undefined

100
Q

What will be the output of the following?
console.log(x);
var x = “APPLE”;
function checkloc() {
console.log(x);
}
checkloc();

A

undefined
APPLE

101
Q

What is the output of the following?
checkloc();
console.log(x);
function checkloc() {
x = “APPLE”;
console.log(x);
}

A

APPLE
APPLE

(so long as the function is called first, x becomes global)

102
Q

What is the output of the following?
checkloc();
console.log(x);
function checkloc() {
var x = “APPLE”;
console.log(x);
}

A

Error!

103
Q

What is the least ambiguous way of accessing a global variable, x, from within a function definition?

A

window.x

104
Q

The following is valid JS code:
const PI;

A

False, const variables must be assigned a value at
declaration.

105
Q

Create a new object, C1, and give it two attributes, a1 & a2.

A

var C1 = new Object();
C1.a1 = “A”;
C1.a2 = “B”;

106
Q

How would delete an attribute, a1, from an object C1?

A

delete C1.a1;

107
Q

Can object properties can be accessed using array notation?
ex. var p1Copy = myObject[“p1”];

A

Yes.

108
Q

Create a new object, C1, and give it two attributes, a1 & a2, using the JSON way.

A

var C1 = { a1: “A”, a2: “B” };

109
Q

Can you use const to declare objects?

A

Yes.

110
Q

Can you change/add properties to objects declared with const?

A

Yes - you just can’t reassign the name being used for that object.

111
Q

Write a loop that would allow you to traverse the properties of an object, C1.

A

for (var prop in C1) { … }

112
Q

Write a conditional statement that checks for the existence of property a1 in object C1.

A

‘a1’ in C1

113
Q

What does the instanceof operator do?

A

Returns true if the LHS variable holds an instance of the a specific object class, which is specified by the constructor for that class on the RHS.

114
Q

What is the output of the following?
var myCar = {make:”ford”, model: “Contour SVT”};
console.log(myCar instanceof myCar);

A

ERROR - the RHS “myCar” is an instance, not the name of a defined class.

115
Q

You can’t add/change elements of an array declared with const.

A

False - you simply can’t reassign the name used for it.

116
Q

What is the output of the following?
var s1 = new String(“A”);
var s2 = “A”;
console.log(s1 instanceof String);
console.log(s2 instanceof String);

A

true
false

(Strings are necessarily objects)

117
Q

What is the output of the following?
var l1 = new Array(1, 2, 3);
var l2 = [1, 2, 3];
console.log(l1 instanceof Array);
console.log(l2 instanceof Array);

A

true
true

(Arrays are necessarily objects)

118
Q

What is returned by a function with no ‘return’?

A

undefined

119
Q

Are functions objects in JS?

A

Yes.

120
Q

What is returned by a function with ‘return’, but no return parameter.

A

undefined

121
Q

Missing/excess function parameters cause JS to crash.

A

False - missing parameters are given the value ‘undefined’ and excess parameters may simply be ignored.

122
Q

Can functions be passed as parameters in JS?

A

Yes.

123
Q

Will arr.sort(f) sort arr (an array of numbers) in increasing or decreasing order?
function f(a, b) {
return a - b;
}

A

Increasing order.

124
Q

Does the default sort() (no parameters) work on arrays of numbers/strings?

A

Strings, yes, but not numbers.

125
Q

A function passed as parameter to sort will either return a number less than, equal to, or greater than 0. How are the two parameters to the passed function, a & b treated depending on the outcome?

A

If a number less than 0 is returned, a is sorted to a lower index than b. If 0 is returned, a and b are considered equal. If a number greater than 0 is returned, a is sorted to a higher index than b.

126
Q

Define a constructor for an object, C1, which has 2 attributes, a1 & a2.

A

function C1(a1, a2) {
this.a1 = a1;
this.a2 = a2;
}

127
Q

Write a function that writes the attributes, a1 & a2, of an object C1 to the html document.

A

function displayC1() {
document.write(this.a1, this.a2);
}

128
Q

How can you make changes to the template of an object?

A

Using Object.prototype

129
Q

Do changes to Object.prototype affect all instances of that object?

A

Yes.

130
Q

Can you put functions into an object’s prototype?

A

Yes.

131
Q

In JS, prototypes are used to build longer chains of …?

A

Inheritance.

132
Q

new RegExp() is a valid built-in JS constructor.

A

True.

133
Q

new Function() is a valid built-in JS constructor.

A

True.

134
Q

Can you define JS classes … SLIDE 30, 4.4

A
135
Q

When defining a class in the following format (in JS), how would you define the constructor?
class C1 { … }

A

constructor(a1, a2) {
this.a1 = a1;
this.a2 = a2;
}

136
Q

Assume class C1 { … } has been defined with 2 string attributes, a1 & a2. How would you then create an instance of it?

A

const c1 = new C1(“hi”, “bye”);

137
Q

What are the 2 primary pattern matching methods, and what do they return?

A

str.search(reg) which returns the index of the matching string (or -1) and str.match(reg) which returns the matching string (or an array of matches).

138
Q

When does .match() return an array, rather than a string?

A

When the passed pattern has the global flag ‘/g’.

139
Q

Can we return all substrings that match a specified regex, without including the global flag in that regex?

A

Yes, using the .matchAll() method rather than .match().
(this returns an iterator, and not an array)

140
Q

How many matches does the following return?
‘abc’.match(/[abc]/g);

A

3

141
Q

How many matches does the following return?
‘abc’.match(/[a-b]/g);

A

2

142
Q

How many matches does the following return?
‘abc’.match(/abc/g);

A

1

143
Q

How many matches does the following return?
‘abc’.match(/[^abc]/g);

A

0
(^ is negation within [brackets])

144
Q

How many matches does the following return?
‘abc’.match(/^[abc]/g);

A

1
(^ implies left-end search outside [brackets])

145
Q

What will the following regex match agaisnt?
/./

A

Any single character, except newline or line terminator.

146
Q

Write the the long form of the following regex.
/\d/

A

/[0-9]/

147
Q

Write the the long form of the following regex.
/\D/

A

/[^0-9]/

148
Q

Write the the long form of the following regex.
/\w/

A

/[A-Za-z_0-9]/
(underscores are also valid)

149
Q

Write the the long form of the following regex.
/\W/

A

/[^A-Za-z_0-9]/

150
Q

Write the the long form of the following regex.
/\s/

A

/[ \r\t\n\f]/
(any 1 of 5 possible whitespace characters)

151
Q

Write the the long form of the following regex.
/\S/

A

/[^ \r\t\n\f]/

152
Q

What does the following regex quantifier do?
{4}

A

Exactly 4 repetitions of the previous character.

153
Q

What does the following regex quantifier do?
{4,}

A

At least 4 repetitions of the previous character.

154
Q

What does the following regex quantifier do?
{4, 6}

A

At least 4 (but no more than 6) repetitions of the previous character.

155
Q

Will the following return a match?
‘aaaa’.match(/a{2,3}/);

A

Yes - aaa

156
Q

Will the following return a match?
‘aaaa’.match(/a{2,}/);

A

Yes - aaaa

157
Q

What’s the difference between the following regex quantifiers?
*, +, ?

A
  • is zero or more repetitions,
    + is one or more repetitions,
    ? is zero or one repetitions.
158
Q

What are the two regex anchors?

A

^ and $

159
Q

How many matches does the following return?
‘abc’.match(/[abc]$/g);

A

1

160
Q

How many matches does the following return?
‘abc’.match(/^[abc]$/g);

A

0
(just ‘a’/’b’/’c’ would’ve returned 1 match)

161
Q

What value does the following return?
‘abc abc’.search(/[^abc]/)

A

3

162
Q

What are the 3 common pattern modifiers?

A

i, g, m.

163
Q

What does the i regex modifier do?

A

i ignores the case of letters.

164
Q

What does the g regex modifier do?

A

Returns all matches, instead of just the first.

165
Q

What does the m regex modifier do?

A

Regex applies to mulitple lines.

166
Q

How do the ^ and $ anchors behave in multiline mode? (m)

A

^ matches beginning of line or beginning of string, and $ matches end of line or end of string.

167
Q

What method allows me to replace instances of a regex (reg) match in a string, str1, with a new string, str2.

A

str1.replace(reg, str2);
(also accepts strings in place of the regex).

168
Q

What method returns a string, str1, as an array split at a specified regex, reg?

A

str1.split(reg);
(also accepts strings, and an optional second parameter to limit the length of the array).

169
Q

5.1 slide 1

A

ok

170
Q

How many versions of DOM is there?

A

4 (DOM 0 - DOM 3)

171
Q

When was the latest DOM standard (DOM 3) approved?

A

2004

172
Q

What does DOM stand for?

A

Document Object Model

173
Q

JS’s Window object has what property?

A

document - a reference to the Document object that the window displays.

174
Q

document.forms[0].elements[0] is a valid way of accessing the first element of the html document’s first form.

A

True - although it is better to use the name attribute.

175
Q

What form element(s) have an implicit array?

A

Checkboxes and radio buttons.

176
Q

What name is given to the process of connecting an event handler to an event?

A

Registration

177
Q

Event handlers can only be assigned directly in the html as an attribute.

A

False - you may also assign the handler as a property in JS.

178
Q

What are the 3 ways in which an HTML element can get focus?

A

When the user clicks on it, when the user tabs to it, or when it is the target of the focus() method.

179
Q

When is the ‘load’ event triggered?

A

When the loading of a document is completed.

180
Q

What is a disadvantage of registering handlers in JS?

A

There is no way to use parameters.

181
Q

What are 2 advantages to registering handlers in JS?

A

It is good to keep HTML and JS separate, and the handler could be changed during use.

182
Q

What are the 6 possible values of position?

A

absolute, relative, static, fixed, inherit and sticky.

183
Q

What is the default value of the position property?

A

static

184
Q

Are statically positioned elements affected by the top/bottom/left/right properties?

A

No.

185
Q

How do relatively positioned elements behave?

A

They are positioned relative to their normal position using the top/right/bottom/left properties.

186
Q

How do fixed positioned elements behave?

A

They are positioned relative to the viewport (they don’t move when scrolling) using the top/bottom/left/right properties.

187
Q

How do absolutely positioned elements behave?

A

They are positioned relative to the nearest positioned ancestor (ancestor that is positioned relatively) using the top/bottom/left/right properties.

188
Q

How do sticky positioned elements behave?

A

These toggle between relative and fixed, depending on the scroll position.

189
Q

Which position value results in an element that can’t be moved using JS?

A

Static.

190
Q

Is space on the page still taken up by an element who’s visibility property is set to “hidden”?

A

Yes.

191
Q

What’s the default value of the visibility property?

A

visible

192
Q

How could you make an element invisible and not take any space? (as if it weren’t there)

A

Set it’s display property to none.

193
Q

Write the code to change a link’s colour once the moues hovers over it (the colour must not change back). Use an event.

A

onmouseover = “this.style.color = ‘blue’;”

194
Q

What JS property is associated with the CSS z-index?

A

zIndex

195
Q

What properties of an event object give the coordinates of the element that caused that event?

A

clientX/clientY or screenX/screenY

196
Q

The clientX & clientY properties are relative to what?

A

The upper left corner of the client (browser) area.

197
Q

The screenX & screenY properties are relative to what?

A

To the upper left corner of the user’s screen (monitor).

198
Q

What 2 window object methods all us to animate objects in JS?

A

setTimeout and setInterval

199
Q

What does JS’s “static scoping” entail?

A

Inner functions have access to the variables/parameters of its outer functions.

200
Q

What does JS’s “closure” entail?

A

The scope that an inner function enjoys continues even after the parent functions have returned.

201
Q

What is the canvas element in html? (as of HTML5)

A

It creates a rectangle into which bit-mapped graphics can be drawn using JavaScript.

202
Q

What does the navigator give you access to? (As of HTML5)

A

Browser information, such as language, userAgent, cookieEnabled, appVersion, appName.

203
Q

What makes a webpage dynamic?

A

Client side scripting & server side scripting (which generates content before sending it to the client).

204
Q

When is ‘value’ used over ‘innerHTML’?

A

For form elements.

205
Q

What does .innerHTML return?

A

The child elements/text of the calling object.

206
Q

What are the 3 phases of the DOM2 event model?

A

(1) Capture phase
(2) Target phase
(3) Bubbling phase