Javascript Dev 1 Cert Flashcards

1
Q

The name of a variable is called ___

A

Identifier

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

____ can be used to declare a local or global variable and can be initialed to a value

A

var

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

____ can be used to declare a block-scoped, local variable and can be initialized

A

let

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

___ can be used to declare a block-scoped, read-only constant. It must be initialized to a value.

A

const

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

What is the value of var1?

let var1;

A

undefined

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

What is the value of var1?

var var1;

A

undefined

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

What data type is this?

let var1 = 123444555666777n;

A

BigInt

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

What is the output?

let field1 = Symbol('field');
let field2 = Symbol('field');
console.log(field1 === field2);
console.log(Symbol('field') == Symbol('field'));
A

false
false

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

What is the output?

let record = {};
record = null;
console.log(typeof record);
A

object

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

What is the output?

let var1 = undefined;
let var2 = null;
console.log(var1 == var2);
A

true

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

What is the output?

let var1 = NaN;
let var2 = NaN;
console.log(var1 == var2);
console.log(var1 === var2);
A

false
false

nothing is ever equal to NaN

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

What is the output?

let var1 = -0;
let var2 = 0;
console.log(var1 == var2);
console.log(var1 === var2);
A

true
true

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

What is the output?

const bool = true;
const str = '5';

console.log(str == 5);
A

true

trick question! don’t let this mess you up

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

What is the output?

const bool = true;

console.log(bool == 5);
A

false

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

What is the output?

const bool = true;

console.log(+bool);
console.log(typeof +bool);
A
1
Number
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
16
Q

What is the output?

const str = '5';

console.log(+str);
console.log(typeof +str);
A
5
Number
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
17
Q

What is the output?

const bool = true;
const str = '5';

console.log(bool & str);
console.log(bool && str);
A

1
5

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

What is the output?

const bool = true;
const str = '5';

console.log(bool == str);
console.log(bool === str);
A

false
false

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

What is the output?

let name;
console.log(typeof name);
A

undefined

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

What is the output?

console.log(Array.from('123'));

A

[“1”, “2”, “3”]

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

What is the output?

Array.of('jan', 'feb', 'mar');
A

[“jan”, “feb”, “mar”]

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

What character is used to define a template literal string?

A

Backtick character (`)

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

When a date object is created, what does it actually contain?

A

A number representing the number of milliseconds since 00:00:00 UTC on January 1st, 1970.

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

What are two ways to create a number?

A

A number literal and the Number constructor.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
25
What does the bigint data type allow?
Storing and operating on big numbers
26
Which keyword should be used to define a value that should not change in the application?
const
27
What type of coercion is automatically performed?
Implicit coercion
28
If the value of ‘data’ is a string, which data type will it be coerced to when data == 0 is used to check its value?
Number
29
To explicitly convert a boolean, what function is used?
Boolean()
30
___ can be used to check whether a given value evaluates to true or false
!! (double bang)
31
___ can be used to check whether a given expression evaluates to true and execute code accordingly.
Conditional (ternary) operator
32
The ___ operator performs type conversion before comparing two values
loose equality operator (==)
33
The ___ operator compares both type and value
strict equality operator (===)
34
# what is the output? {} == {a: 1, b:2}
false
35
# what is the output? [] == [1, 2]
false
36
# what is the output? [1] == [1]
false
37
# what is the output? [1] === [1]
false
38
# what is the output? {} == {}
false
39
# what is the output? {} === {}
false
40
# truthy or falsey ‘0’ //(string containing 0)
truthy
41
# truthy or falsey ‘false’ (string containing false)
truthy
42
# truthy or falsey 47 (a number other than 0 and -0)
truthy
43
# truthy or falsey Infinity
truthy
44
# truthy or falsey -Infinity
truthy
45
# truthy or falsey 0 (the number 0)
falsey
46
# truthy or falsey -0 (the number negative 0)
falsey
47
# truthy or falsey 0n (BigInt 0)
falsey
48
# truthy or falsey ‘’ (empty string)
falsey
49
# truthy or falsey null
falsey
50
# truthy or falsey undefined
falsey
51
# truthy or falsey NaN (not a number)
falsey
52
# What is the output? ``` const array1 = [1, 2, 3, 4]; const initialValue = 1; const sumWithInitial = array1.reduce( (accumulator, currentValue) => accumulator + currentValue, initialValue ); console.log(sumWithInitial); ```
11
53
# What is the output? ``` const colors = ['Blue', 'Green', 'Yelow', 'Purple']; console.log(colors); months.splice(1, 0, 'Red'); console.log(colors); colors.splice(4, 1, 'Orange'); console.log(colors); ```
['Blue', 'Green', 'Yelow', 'Purple'] ['Blue', 'Red', 'Green', 'Yelow', 'Purple'] ['Blue', 'Red', 'Green', 'Yelow', 'Orange']
54
# What is the output? ``` const array1 = [1, 2, 3]; console.log(array1.unshift(4, 5)); console.log(array1); ```
Array [4, 5, 1, 2, 3]
55
# What is the output? ``` const plants = ['broccoli', 'cauliflower', 'cabbage', 'kale', 'tomato']; console.log(plants.pop()); console.log(plants); plants.pop(); console.log(plants); ```
"tomato" Array ["broccoli", "cauliflower", "cabbage", "kale"] plants.pop(); Array ["broccoli", "cauliflower", "cabbage"]
56
# What is the output? ``` const plants = ['broccoli', 'cauliflower', 'cabbage', 'kale', 'tomato']; console.log(plants.pop()); console.log(plants); plants.pop(); console.log(plants); ```
"tomato" Array ["broccoli", "cauliflower", "cabbage", "kale"] plants.pop(); Array ["broccoli", "cauliflower", "cabbage"]
57
# What is the output? ``` const animals = ['ant', 'bison', 'camel', 'duck', 'elephant']; console.log(animals.slice(2)); console.log(animals.slice(2, 4)); console.log(animals.slice(1, 5)); console.log(animals.slice(-2)); console.log(animals.slice(2, -1)); console.log(animals.slice()); ```
['camel', 'duck', 'elephant'] ['camel', 'duck'] ['bison', 'camel', 'duck', 'elephant'] ['duck', 'elephant'] ['camel', 'duck'] ['ant', 'bison', 'camel', 'duck', 'elephant']
58
# What is the output? ``` const words = ['spray', 'limit', 'elite', 'exuberant', 'destruction', 'present']; const result = words.filter(word => word.length > 6); console.log(result); ```
Array ["exuberant", "destruction", "present"]
59
# What is the output? ``` const array = [1, 2, 3, 4, 5]; // Checks whether an element is even const even = (element) => element % 2 === 0; console.log(array.some(even)); ```
true
60
# What is the output? ``` const isBelowThreshold = (currentValue) => currentValue < 40; const array1 = [1, 30, 39, 29, 10, 13]; console.log(array1.every(isBelowThreshold)); ```
true
61
# What is the output? ``` const array1 = [1, 4, 9, 16]; // Pass a function to map const map1 = array1.map(x => x * 2); console.log(map1); ```
Array [2, 8, 18, 32]
62
# What is the output? ``` const kvArray = [ { key: 1, value: 10 }, { key: 2, value: 20 }, { key: 3, value: 30 }, ]; const reformattedArray = kvArray.map(({ key, value }) => ({ [key]: value })); console.log(reformattedArray); console.log(kvArray); ```
[{ 1: 10 }, { 2: 20 }, { 3: 30 }] [ { key: 1, value: 10 }, { key: 2, value: 20 }, { key: 3, value: 30 } ]
63
# What is the output? ``` const array1 = [5, 12, 8, 130, 44]; const found = array1.find((element, index, arraycopy) => element > 10); console.log(found); ```
12
64
# What is the output? ``` const arr1 = [0, 1, 2, [3, 4]]; console.log(arr1.flat()); const arr2 = [0, 1, 2, [[[3, 4]]]]; console.log(arr2.flat(2)); ```
[0, 1, 2, 3, 4] [0, 1, 2, [3, 4]]
65
# What is the output? ``` const animals = ['ant', 'bison', 'camel', 'duck', 'elephant']; console.log(animals.slice(2)); console.log(animals.slice(2, 4)); ```
['camel', 'duck', 'elephant'] ['camel', 'duck']
66
# What is the output? ``` function doSomething(){ console.log('message ' + message); var message = 'hello '; } ```
message undefined
67
# What is the output? ``` console.log(hoist); var hoist = 'hi'; ```
undefined
68
What are the falsy values?
false 0 -0 0n ‘’ null undefined NaN
69
What function can be used to determine the boolean value of any variable?
Boolean()
70
How is the strict equality operator different from the loose equality operator?
The strict equality operator verifies that both the value and data type of the operands match
71
What does JSON stand for?
JavaScript Object Notation
72
What methods can be used to change the value of the keyword ‘this’?
call, apply, and bind ``` thing.call(this, param1, param2, param3); thing.bind(this, param1, param2, param3)(); thing.apply(this, [param1, param2, param3]); ```
73
When working with an iterator or generator, what method is used to access the next value?
next()
74
What are the two ways to access an object property?
Dot notation and bracket notation.
75
What is the object called that another object inherits from?
Prototype
76
What method is used to identify if an object owns a particular property and is not borrowing it from a prototype?
hasOwnProperty()
77
What are the two ways of creating a class in JavaScript?
Class declaration Class expression
78
What keyword causes a class to inherit from another class?
extends
79
What type of inheritance is used when using a class constructor?
Prototypal inheritance
80
What are the three types of variable scopes in JavaScript?
Global scope local scope(function scope) block scope
81
What are the keywords that enable the creation of block scoped variables?
let and const
82
What are the two main types of execution context in JavaScript?
Global execution context Function execution context
83
What is the syntax for exporting function ‘composeData’ as the default?
export default composeData;
84
What is the correct statement for importing function ‘multiply’ and object ‘data’ from ‘./util.js’?
import { multiply, data} from ‘./util.js’;
85
What does the statement that modules are imported as ‘live bindings’ mean?
Values imported from a module are updated by that module. If a value is changed, it will be reflected in the code that imports and uses it.
86
What is the correct statement for importing function ‘multiply’ and object ‘data’ from ‘./util.js’?
import { multiply, data} from ‘./util.js’;
87
What does the statement that modules are imported as ‘live bindings’ mean?
Values imported from a module are updated by that module. If a value is changed, it will be reflected in the code that imports and uses it.
88
How many arguments are passed to a decorator function when it is being used to decorate a class?
1
89
What is the argument that is responsible for the writable attribute of a class property?
descriptor
90
How many arguments are passed to a decorator function when it is being used to decorate a class method?
3
91
What are the two approaches for handling events in JavaScript?
Adding an event listener Using an ‘onevent’ handler.
92
What statement is used to create a custom event?
new CustomEvent(‘eventName’, {optionalDetailsPlacedInObject})
93
What is event bubbling?
The target element receives the event and then any handlers in the elements ancestry will each receive the event in turn.
94
Which API can be used to render shapes on an HTML page?
Canvas API
95
Which API can be used to retrieve JSON strings over a network?
Fetch API
96
Which event is triggered when clicking on either the previous or next page button on a web browser?
The window's popstate event
97
What does the DOM represent?
The structure and content of an HTML document.
98
What command can be used to select all the DOM elements of a particular type?
querySelectorAll()
99
What property can be used to set the HTML content of a DOM element?
innerHTML
100
What can be inspected and modified in the Elements panel?
DOM and CSS
101
Where does one monitor the value of a variable over time?
Watch pane
102
To check if data has been downloaded, what panel should be used?
Network panel
103
What command can be used to log an error to the console?
console.error()
104
How is code execution paused so that variables can be examined?
By creating a breakpoint
105
Where are the currently defined local and global variables displayed?
In the scope pane
106
What is the main advantage of asynchronous code?
It can execute separately from the main code without blocking it.
107
When a promise is returned, what method is used to respond to a successful resolution?
The .then() method
108
How are errors handled in an async function?
Using a try...catch statement
109
What does the runtime engine use to store and manage the functions to run?
Call Stack
110
What pushes a message from the message queue to the call stack for processing?
Event Loop
111
What are the three ways of specifying events to monitor for an object?
Event name Event type Array
112
Which method can be used to create a new instance of http.Server in Node.js?
http.createServer()
113
Which method can be used to read a file asynchronously in Node.js?
fs.readFile()
114
Which module can be used in Node.js to emit and handle events?
The ‘events’ module
115
Which Node.js command can be used to run a JavaScript file named script.js?
node script.js
116
Which npm command can be used to install the webpack library as a development dependency?
npm install webpack --save-dev
117
Which Node.js command can be used to check the syntax of the code without execution?
node --check
118
What are the three types of modules that can be included in a Node.js application?
Core local third-party modules
119
Which core module can be used to work with the file system in Node.js?
The ‘fs’ module
120
Which third-party module can be used to handle incoming HTTP requests in Node.js?
Express
121
When following the semantic versioning spec, how should the version number of a package be updated in case of a patch release?
The third digit of the version number should be incremented. For example, 1.0.3 should be changed to 1.0.4.
122
Which command allows checking if there are installed packages that are outdated?
npm outdated
123
Which command can be used to update an npm package named ‘lodash’ that is installed locally?
npm update lodash
124
What console API method can be used to test an assertion?
console.assert()
125
What is a false negative?
The test instance failed due to a defect in the test, not the code being tested.
126
In which testing approach is the internal structure of the application not known?
Black-box testing
127
# Which 3 statements will produce a Boolean value of True? ``` let val1 = 100; let val2 = '100'; ``` A. val1 || val2; B. val1 == val2; c. !!val2; d. val1 && val2; e. val1 === Number(val2);
val1 == val2; !!val2; val1 === Number(val2)
128
# Which would result in NaN being assigned to num? A. const num = 1/ Number('true') B. const num = 1/ new Number(true) C. const num = 1/ Number('1000') D. const num = 1/ false
const num = 1/ Number('true')
129
____ is a library with the ability to perform deep comparisons between two objects with the _.isEqual() method
lodash
130
How any parameters are passed to a decorator function that is used to decorate a class method?
Three
131
What is the first argument passed to a decorator function that is used to decorate a class method?
target
132
What is the second argument passed to a decorator function that is used to decorate a class method?
name
133
What is the third argument passed to a decorator function that is used to decorate a class method?
descriptor
134
What values does the Promise state property have?
Pending Rejected Fulfilled
135
What is the difference between slice and splice?
Slice returns a new array from the original Splice adds/removes from the original
136
What does the unshift() method do?
The unshift() method adds one or more elements to the beginning of an array and returns the new length of the array.
137
What does the shift() method do?
The shift() method removes the first element from an array and returns that removed element. This method changes the length of the array.
138
Given this code, how do you retreive only the directory of the given file? (choose 2) ``` const path = require('path'); const file = '/employees/person.txt'; ``` A. path.dirname(file); B. path.normalize(file).dir; C. path.parse(file).dir; D. path.dir(file);
path.dirname(file); path.parse(file).dir;
139
What are 3 ways to create Objects?
Object Literal Object Constructor Object.create
140
For var x, how do you create a new object as a literal?
`var x = {}`
141
For var x, how do you create a new object as constructor?
`var x = new Object()`
142
For var x, how do you create a new object with .create?
``` var obj = { name : "foo" } var x = Object.create(obj); ```
143
What two ways can you call typeof?
``` typeof operand typeof(operand) ```
144
# What is the output? ``` typeof (typeof 1) ```
"string"
145
# What is the output? ``` typeof !!(-1) ```
"boolean"
146
# What is the output? ``` typeof function(){} ```
"function"
147
# What is the output? ``` typeof new Date() ```
"object"
148
# What is the output? ``` typeof null ```
"object"
149
# What is the output? ``` Number(39) ```
39
150
# What is the output? ``` Number(undefined) ```
NaN
151
# What is the output? ``` Number('hello') ```
NaN
152
# What is the output? ``` Number(" 45 ") ```
45
153
# What is the output? ``` Number("\t") ```
0
154
# What is the output? ``` Number('3x') ```
NaN
155
# What is the output? ``` Number(null) ```
0
156
# What is the output? ``` Number(false) ```
0
157
# What is the output? ``` Number(true) ```
1
158
# What is the output? ``` Number([]) ```
0
159
# What is the output? ``` Number(['33']) ```
33
160
# What is the output? ``` Number(['33', '32']) ```
NaN
161
# What is the output? ``` Boolean(2) ```
true
162
# What is the output? ``` Boolean({}) ```
true
163
# What is the output? ``` Boolean([]) ```
true
164
# What is the output? ``` Boolean('2') ```
true
165
# What is the output? ``` Boolean('') ```
false
166
# What is the output? ``` Boolean(null) ```
false
167
# What is the output? ``` Boolean(0) ```
false
168
# What is the output? ``` Boolean(undefined) ```
false
169
# What is the output? ``` Boolean(false) ```
false
170
# What is the output? ``` Boolean(NaN) ```
false
171
# What is the output? ``` Boolean(0n) ```
false
172
# What is the output? ``` Boolean(1324n) ```
true
173
# What is the output? ``` 100 + 'world' ```
'100world'
174
# What is the output? ``` 'foo' + 100 ```
'foo100'
175
# What is the output? ``` 100 + null + 30 + 'foo' ```
'130foo'
176
# What is the output? ``` 100 + 400 + undefined + 'foo' ```
'NaNfoo'
177
# What is the output? ``` var x = {} x+'foo' ```
"[object Object]foo"
178
# What is the output? ``` 100 == '100' ```
true
179
# What is the output? ``` 100 === '100' ```
false
180
# What is the output? ``` true == 'true' ```
false
181
# What is the output? ``` NaN === NaN ```
false
182
# What is the output? ``` -0 === 0 ```
true
183
# What is the output? ``` Object.is(-0, 0) ```
false
184
# What is the output? ``` s() var s = function{ console.log('hi); } ```
uncaught error s is not a function
185
# What is the output? ``` "use strict"; x = 3.14; ```
uncaught syntax error: x is not defined
186
# What is the output? ``` "use strict"; var x = 3.14; delete x; ```
uncaught syntax error: delete of an unqualified identifier in strict mode
187
# What is the output? ``` "use strict"; function x (p1, p1){}; ```
uncaught syntax error: duplicate parameter name not allowed in this context
188
# What is the output? ``` var func = new Function('a', 'b', 'return a*b'); func(4,3); ```
12
189
# What is the output? ``` [...'hello'] ```
['h','e','l','l','o']
190
# What is the output? ``` var employee = {fName: 'hi', lName : 'hello'}; var {fName, lName} = employee fName; lName; ```
hi hello
191
# What is the output? ``` function outer(){ var counter = 0; return function inner(){ counter += 1 return counter }} var counter = outer(); counter(); counter(); counter(); ```
3
192
What does location.assign do?
loads a new document
193
What does Navigator.online do
returns true / false on if connected to internet
194
# What way is this Object being instantiated? ``` var x = {} var detail = { name: "nikhil" } ```
Object literal
195
# What way is this Object being instantiated? ``` var x = new Object() x.name = "dude" console.log(x) ```
Object constructor
196
# What way is this Object being instantiated? ``` var obj = { name: "dude" } var newObj = Object.create(obj) ```
Object.create() method
197
# What is the output? typeof NaN
Number
198
# What is the output? ``` typeof 0 ```
Number
199
# What is the output? typeof "true"
String
200
# What is the output? ``` var x typeof x ```
undefined
201
# What is the output? ``` typeof null ```
object
202
# What is the output? ``` typeof {} ```
object
203
# What is the output? ``` typeof !!(1) ```
Boolean
204
# What is the output? ``` typeof function () { } ```
function
205
# What is the output? ``` typeof new Date() ```
Object
206
# What is the output? ``` String(undefined) ```
'undefined'
207
# What is the output? ``` String(true) ```
'true'
208
# What is the output? ``` Number(Symbol()) ```
TypeError thrown, as symbols cannot be converted to a Number
209
# What is the output? ``` String([]) ```
''
210
# What is the output? ``` String({}) ```
[object Object]
211
# What is the output? ``` String([a:1,b:2]) ```
[object Object]
212
# What is the output? ``` String([5,10,15]) ```
5,10,15
213
# What is the output? ``` String(null) ```
'null'
214
# What is the output? ``` String(Symbol('hello')) ```
Symbol('hello')
215
# What is the output? ``` Number(null) ```
0
216
# What is the output? ``` Number(undefined) ```
NaN
217
# What is the output? ``` Number('hello') ```
NaN
218
# What is the output? ``` Number([]) ```
0
219
# What is the output? ``` Number([33, 33]) ```
NaN
220
# What is the output? ``` Number(['52']) ```
52
221
# What is the output? ``` Boolean('') ```
false
222
# What is the output? ``` Boolean(' ') ```
true
223
# What is the output? ``` Boolean(undefined) ```
false
224
# What is the output? ``` Boolean(null) ```
false
225
# What is the output? ``` Boolean(NaN) ```
false
226
# What is the output? ``` NaN == NaN ```
false
227
# What is the output? ``` NaN === NaN ```
false
228
# What is the output? ``` - 0 == 0 ```
true
229
# What is the output? ``` - 0 === 0 ```
true
230
# What is the output? ``` [] === [] ```
false
231
# What is the output? ``` [] == [] ```
false
232
# What is the output? ``` Object.is(100, "100") ```
false
233
# What is the output? ``` var x = 10 console.log(x++) ```
10
234
# What is the output? ``` var x = 10 x++ console.log(x); ```
11
235
# What is the output? ``` var x = [] var y = x x === y ```
true
236
# What is the output? ``` "Hello" + "World" + "16546542" ```
'HelloWorld16546542'
237
# What is the output? ``` 100 + "world" ```
'100world'
238
# What is the output? ``` 100 + null + 20 + "world" ```
'120world'
239
# What is the output? ``` true + 1 + "hey" ```
'2hey'
240
# What is the output? ``` undefined + 2 ```
NaN
241
# What is the output? ``` null + 2 ```
2
242
# What is the output? ``` 100 + 200 + undefined + "hey" ```
NaNhey
243
# What is the output? ``` undefined + 2 + 'no' ```
NaNno
244
# What is the output? ``` JSON.parse("'str'") ```
``` Uncaught SyntaxError: Unexpected token ''' "'str'" is not valid JSON at JSON.parse () at :1:6 ```
245
# What is the output? ``` JSON.parse("str") ```
``` Uncaught SyntaxError: Unexpected token 's', "str" is not valid JSON at JSON.parse () at :1:6 ```
246
# What is the output? ``` JSON.parse('str') ```
``` Uncaught SyntaxError: Unexpected token 's', "str" is not valid JSON at JSON.parse () at :1:6 ```
247
# What is the output? ``` '"' JSON.parse('"str"') ```
'str'
248
# What command is used to install pre-reqs for this code? ``` const fs = require('fs') const _ = require('lodash') ```
npm i lodash | npm install lodash ## Footnote note: fs comes with Node.js so this is redundant
249
What is a black box test?
A test that only considers the external behavior of the system
250
What is a white box test?
A method used to test a software taking into consideration its internal functioning
251
What javascript statement can be used to insert a 'newelementdiv' after 'markerelement'?
`document.body.insertBefore(newelementdiv, markerElement.nextSibling)`
252
Which pane in the browser Devtools shows information about the defined local and global variables and their values? * Global Pane * Scope Pane * Variables Pane * Breakpoints Pane
Scope Pane
253
# In package.json, what versions can be installed with ~ ~1.2.3
releases from 1.2.3 to <1.3.0.
254
# In package.json, what version will be installed with ~2.2.0 * 2.2.3 * 3.0.1 * 2.2.1 * 2.3.1
2.2.3
255
# In package.json, what versions can be installed with ^ ^1.2.3
releases from 1.2.3 to <2.0.0
256
# What will advance to line 2 in execution? * node app.js, debug next * node app.js, debug * node debug appj.js, n * node inspect app.js, next
node inspect app.js, next
257
How many arguments does the reduce() method take? What do the argument(s) do?
2 required, can be passed as a function or an array ``` //function const numbers = [15.5, 2.3, 1.1, 4.7]; document.getElementById("demo").innerHTML = numbers.reduce(getSum, 0); function getSum(total, num) { return total + Math.round(num); } //array const numbers = [175, 50, 25]; document.getElementById("demo").innerHTML = numbers.reduce(myFunc); function myFunc(total, num) { return total - num; } ```
258
# What is the output? Number.isNaN('hello')
false ## Footnote this is false because Number.isNan method only checks if the value is equal to NaN
259
# What is the output? isNaN('hello')
true ## Footnote this is true because the global method isNaN checks whether the passed value **is not a number** or **cannot be converted into a Number**
260
# What is the output? ``` const bool = true; const str = '5'; console.log(bool == 5); ```
false
261
What are 3 ways to loop through arrays?
``` for(let i = 0; i < customers.length; i ++) {} for(const index in customers) {} customers.forEach(customer =>{}) ```
262
263
# What is the output? ``` const numbers = [3, 1, 4, 1, 5]; const sorted = numbers.sort((a, b) => a - b); sorted[0] = 10; console.log(numbers[0]); ```
10
264
# What is the output? ``` const numbers = [3, 1, 4, 1, 5]; const sorted = [...numbers].sort((a, b) => a - b); sorted[0] = 10; console.log(numbers[0]); ```
3
265
# What is the output? ``` const bool = false; const str = '5'; console.log(bool & str); console.log(bool && str); ```
``` 0 false ```
266
What are the characteristics of a white box test? * Testing can be automated * Testing a particular functionality is less complex * It represents a functional test of the software * The focus is on testing structures, objects and functions * Testing is mostly performed by software developers
* Testing can be automated * The focus is on testing structures, objects and functions * Testing is mostly performed by software developers
267
In nodeJS, how do you write a body JSON?
response.write(jsonStr);