Intermediate JavaScript Flashcards

1
Q

What is the DOM

A

Document Object Model

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

What is the Virtual DOM?

A

A virtual DOM is a lightweight JavaScript representation of the DOM used in declarative web frameworks such as React, Vue.js, and Elm. Updating the virtual DOM is comparatively faster than updating the actual DOM.

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

Window Object

A

Represents the browser window

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

Document Object

A

Represents the web page

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

Image Object

A

Represents an HTML IMG tag

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

History Object

A

Contains browser history

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

Navigator Object

A

Contains niformation about the visitor’s browser

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

All global JS objects, functions and variables automatically become….

A

members of the window object

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

Global variables (Window object) are…

A

properties of the window object

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

Global functions (window object) are..

A

methods of the window object

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

Some methods of the Window Object

A

window. open
window. close
window. moveTo
window. resizeTo

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

Finding HTML (Document Object), few examples

A

getElementsById
getElementsByTagName
getElementsByClassName

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

Changing HTML (Document Object)

A

element. innerHTML =
element. attribute =
element. setAttribute (attribute,value)

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

Adding or Deleting Elements (Document Object)

A

document. createElement(element)
document. removeChild(element)
document. appendChild(element)

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

Event Handler (Document Object)

A

document.getElementById(id).onclick = function () {code}

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

Create an Image Object

A

const x = document.createElement(“IMG”)

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

Some Image Object properties

A

complete
naturalHeigth
naturalWidth
src

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

Image rollover?

A

Two images. Change onMouseOver and onMouseOut

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

Return the anchor part of a URL (Location Object)

A

var x = location.hash;

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

Which Methods are there for the Location Object?

A

assign() Loads a new document
reload() Reloads the current document
replace() Replaces the current document with a new one

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

Difference between replace or assign (location object)

A

After using replace the current page will not be saved in the session history

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

Which Navigator propertie returns the version of the browser?

A

appVersion

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

Which Navigator object returns the operating system?

A

platform

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

Which Navigator property returns the name of the browser?

A

appName

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
25
Which three methods to extract a part of String are there?
slice(start, end) substring(start, end) substr(start, length)
26
What does slice()? (String)
extracts a part of a string and returns the extracted part in a new string.
27
What doest the substring() method?
substring() is similar to slice(). | The difference is that substring() cannot accept negative indexes.
28
What does the substr() method?
substr() is similar to slice(). | The difference is that the second parameter specifies the length of the extracted part.
29
Difference between indexOf() and search() method?
``` The search() method cannot take a second start position argument. The indexOf() method cannot take powerful search values (regular expressions). ```
30
String.match....
The match() method searches a string for a match against a regular expression, and returns the matches, as an Array object.
31
What is a regular expression? Regexp
A regular expression is a sequence of characters that forms a search pattern. The search pattern can be used for text search and text replace operations.
32
In JavaScript, regular expressions are often used with the two string methods: search() and replace().
The search() method uses an expression to search for a match, and returns the position of the match. The replace() method returns a modified string where the pattern is replaced.
33
Regular Expression Patterns
Brackets are used to find a range of characters: Expression [abc] Find any of the characters between the brackets [0-9] Find any of the digits between the brackets (x|y) Find any of the alternatives separated with | Metacharacters are characters with a special meaning: Metacharacter \d Find a digit \s Find a whitespace character \b Find a match at the beginning of a word like this: \bWORD, or at the end of a word like this: WORD\b \uxxxx Find the Unicode character specified by the hexadecimal number xxxx
34
RegExp Object
In JavaScript, the RegExp object is a regular expression object with predefined properties and methods.
35
Reg Exp Object methods
exec() Tests for a match in a string. Returns the first match test() Tests for a match in a string. Returns true or false toString() Returns the string value of the regular expression
36
What type of error is most likely to debug using watchpoints?
Logical
37
What is a typical watchpoint in JS?
alert()
38
What type of error after script has loaded?
Run-time
39
What are run time erros typically caused by?
Improper use of commands
40
Syntax-error
Load time (also called compiler / interpreter error)
41
What to use to repeat a group of statement fora particular range of values?
For loop
42
Control structures...
Make decisions based on Boolean values
43
Substitute for the neste if..else statement?
Switch
44
Purpose of the switch statement?
To compare a value against another to search for a match
45
Purpose of the break statement?
To exit a control structure
46
Continue statement..
Force the flow of control back to the top of the loop
47
How to check if Java is enabled?
Use javaEnabled() method (navigator object)
48
Limitation of virtual DOM?
Changes aren't directly reflected on the webpage
49
The history object has one property....
length
50
What is the JS equivalent fo the browser's back button?
history.go(-1);
51
What is the default object in JS?
Window
52
How to bring a window object to the top?
window.moveTo()
53
Create a new history entry?
pushstate()
54
Diffing =
comparing the new virtual DOM with previous version
55
window.open() method uses 3 segments
URL, window name and list of window
56
Comma delimited list from array
Use myArray.join(",");
57
Declare a regular expression:
var ex = /Ron/;
58
Difference between shift and pop
shift removes and returns the first element, pop the last element
59
How to extract username from var email = ron@outlook.com
email.substring(0, email.indexOf("@") 0 = starting index @ = starting index --> up to (in this case @ )
60
To use any Data or Time you must create a new instance or copy
var mydate = new Date();
61
How to repeat a method or command after x-time
setTimeOut() | function.setTimeOut(time);
62
The join() method, by default, uses the....
comma seperator
63
Why use regular expression instead of string for matching?
regular expression can match a large number of strings
64
Math.random returns...
any value in range 0 - 1 with 0 included and 1 excluded
65
getDate() returns...
The date number (17 if it's 17th of november)
66
Regex, string, Math, Array, Date are....
language objects
67
String length is...
string.length (NOT a method so no brackets)
68
floor, ceil, sin are...
Math objects
69
substr() method takes two parameters...
1. Starting index | 2. Number of characters to extract
70
charAt() example..
firstName.charAt(4);
71
What is a JS class?
``` A JavaScript class is not an object. It is a template for JavaScript objects. ```
72
THe prototype is available in ...... JS object
every
73
Inheritance =
class-based and prototype based
74
Yield operator
Pause or resume a generator function
75
Add additional fields to custom object...
Use prototype
76
Which object can access items in a collection?
Iterator
77
Call the functions on a paretn object?
Use the super keyword