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
Q

What does the bigint data type allow?

A

Storing and operating on big numbers

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

Which keyword should be used to define a value that should not change in the application?

A

const

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

What type of coercion is automatically performed?

A

Implicit coercion

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

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?

A

Number

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

To explicitly convert a boolean, what function is used?

A

Boolean()

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

___ can be used to check whether a given value evaluates to true or false

A

!! (double bang)

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

___ can be used to check whether a given expression evaluates to true and execute code accordingly.

A

Conditional (ternary) operator

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

The ___ operator performs type conversion before comparing two values

A

loose equality operator (==)

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

The ___ operator compares both type and value

A

strict equality operator (===)

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

what is the output?

{} == {a: 1, b:2}

A

false

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

what is the output?

[] == [1, 2]

A

false

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

what is the output?

[1] == [1]

A

false

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

what is the output?

[1] === [1]

A

false

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

what is the output?

{} == {}

A

false

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

what is the output?

{} === {}

A

false

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

truthy or falsey

‘0’ //(string containing 0)

A

truthy

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

truthy or falsey

‘false’ (string containing false)

A

truthy

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

truthy or falsey

47 (a number other than 0 and -0)

A

truthy

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

truthy or falsey

Infinity

A

truthy

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

truthy or falsey

-Infinity

A

truthy

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

truthy or falsey

0 (the number 0)

A

falsey

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

truthy or falsey

-0 (the number negative 0)

A

falsey

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

truthy or falsey

0n (BigInt 0)

A

falsey

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

truthy or falsey

‘’ (empty string)

A

falsey

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

truthy or falsey

null

A

falsey

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

truthy or falsey

undefined

A

falsey

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

truthy or falsey

NaN (not a number)

A

falsey

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

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);
A

11

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

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);
A

[‘Blue’, ‘Green’, ‘Yelow’, ‘Purple’]
[‘Blue’, ‘Red’, ‘Green’, ‘Yelow’, ‘Purple’]
[‘Blue’, ‘Red’, ‘Green’, ‘Yelow’, ‘Orange’]

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

What is the output?

const array1 = [1, 2, 3];

console.log(array1.unshift(4, 5));

console.log(array1);
A

Array [4, 5, 1, 2, 3]

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

What is the output?

const plants = ['broccoli', 'cauliflower', 'cabbage', 'kale', 'tomato'];

console.log(plants.pop());

console.log(plants);

plants.pop();

console.log(plants);
A

“tomato”
Array [“broccoli”, “cauliflower”, “cabbage”, “kale”]
plants.pop();
Array [“broccoli”, “cauliflower”, “cabbage”]

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

What is the output?

const plants = ['broccoli', 'cauliflower', 'cabbage', 'kale', 'tomato'];

console.log(plants.pop());

console.log(plants);

plants.pop();

console.log(plants);
A

“tomato”
Array [“broccoli”, “cauliflower”, “cabbage”, “kale”]
plants.pop();
Array [“broccoli”, “cauliflower”, “cabbage”]

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

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());
A

[‘camel’, ‘duck’, ‘elephant’]
[‘camel’, ‘duck’]
[‘bison’, ‘camel’, ‘duck’, ‘elephant’]
[‘duck’, ‘elephant’]
[‘camel’, ‘duck’]
[‘ant’, ‘bison’, ‘camel’, ‘duck’, ‘elephant’]

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

What is the output?

const words = ['spray', 'limit', 'elite', 'exuberant', 'destruction', 'present'];

const result = words.filter(word => word.length > 6);

console.log(result);
A

Array [“exuberant”, “destruction”, “present”]

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

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));
A

true

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

What is the output?

const isBelowThreshold = (currentValue) => currentValue < 40;

const array1 = [1, 30, 39, 29, 10, 13];

console.log(array1.every(isBelowThreshold));
A

true

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

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);
A

Array [2, 8, 18, 32]

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

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);
A

[{ 1: 10 }, { 2: 20 }, { 3: 30 }]

[
{ key: 1, value: 10 },
{ key: 2, value: 20 },
{ key: 3, value: 30 }
]

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

What is the output?

const array1 = [5, 12, 8, 130, 44];

const found = array1.find((element, index, arraycopy) => element > 10);

console.log(found);
A

12

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

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));
A

[0, 1, 2, 3, 4]
[0, 1, 2, [3, 4]]

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

What is the output?

const animals = ['ant', 'bison', 'camel', 'duck', 'elephant'];

console.log(animals.slice(2));

console.log(animals.slice(2, 4));


A

[‘camel’, ‘duck’, ‘elephant’]
[‘camel’, ‘duck’]

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

What is the output?

function doSomething(){
console.log('message ' + message);
var message = 'hello ';
}
A

message undefined

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

What is the output?

console.log(hoist);
var hoist = 'hi';
A

undefined

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

What are the falsy values?

A

false
0
-0
0n
‘’
null
undefined
NaN

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

What function can be used to determine the boolean value of any variable?

A

Boolean()

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

How is the strict equality operator different from the loose equality operator?

A

The strict equality operator verifies that both the value and data type of the operands match

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

What does JSON stand for?

A

JavaScript Object Notation

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

What methods can be used to change the value of the keyword ‘this’?

A

call, apply, and bind
~~~
thing.call(this, param1, param2, param3);
thing.bind(this, param1, param2, param3)();
thing.apply(this, [param1, param2, param3]);
~~~

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

When working with an iterator or generator, what method is used to access the next value?

A

next()

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

What are the two ways to access an object property?

A

Dot notation and bracket notation.

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

What is the object called that another object inherits from?

A

Prototype

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

What method is used to identify if an object owns a particular property and is not borrowing it from a prototype?

A

hasOwnProperty()

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

What are the two ways of creating a class in JavaScript?

A

Class declaration
Class expression

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

What keyword causes a class to inherit from another class?

A

extends

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

What type of inheritance is used when using a class constructor?

A

Prototypal inheritance

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

What are the three types of variable scopes in JavaScript?

A

Global scope
local scope(function scope)
block scope

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

What are the keywords that enable the creation of block scoped variables?

A

let and const

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

What are the two main types of execution context in JavaScript?

A

Global execution context
Function execution context

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

What is the syntax for exporting function ‘composeData’ as the default?

A

export default composeData;

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

What is the correct statement for importing function ‘multiply’ and object ‘data’ from ‘./util.js’?

A

import { multiply, data} from ‘./util.js’;

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

What does the statement that modules are imported as ‘live bindings’ mean?

A

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.

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

What is the correct statement for importing function ‘multiply’ and object ‘data’ from ‘./util.js’?

A

import { multiply, data} from ‘./util.js’;

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

What does the statement that modules are imported as ‘live bindings’ mean?

A

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.

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

How many arguments are passed to a decorator function when it is being used to decorate a class?

A

1

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

What is the argument that is responsible for the writable attribute of a class property?

A

descriptor

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

How many arguments are passed to a decorator function when it is being used to decorate a class method?

A

3

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

What are the two approaches for handling events in JavaScript?

A

Adding an event listener
Using an ‘onevent’ handler.

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

What statement is used to create a custom event?

A

new CustomEvent(‘eventName’, {optionalDetailsPlacedInObject})

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

What is event bubbling?

A

The target element receives the event and then any handlers in the elements ancestry will each receive the event in turn.

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

Which API can be used to render shapes on an HTML page?

A

Canvas API

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

Which API can be used to retrieve JSON strings over a network?

A

Fetch API

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

Which event is triggered when clicking on either the previous or next page button on a web browser?

A

The window’s popstate event

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

What does the DOM represent?

A

The structure and content of an HTML document.

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

What command can be used to select all the DOM elements of a particular type?

A

querySelectorAll()

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

What property can be used to set the HTML content of a DOM element?

A

innerHTML

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

What can be inspected and modified in the Elements panel?

A

DOM and CSS

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

Where does one monitor the value of a variable over time?

A

Watch pane

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

To check if data has been downloaded, what panel should be used?

A

Network panel

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

What command can be used to log an error to the console?

A

console.error()

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

How is code execution paused so that variables can be examined?

A

By creating a breakpoint

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

Where are the currently defined local and global variables displayed?

A

In the scope pane

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

What is the main advantage of asynchronous code?

A

It can execute separately from the main code without blocking it.

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

When a promise is returned, what method is used to respond to a successful resolution?

A

The .then() method

108
Q

How are errors handled in an async function?

A

Using a try…catch statement

109
Q

What does the runtime engine use to store and manage the functions to run?

A

Call Stack

110
Q

What pushes a message from the message queue to the call stack for processing?

A

Event Loop

111
Q

What are the three ways of specifying events to monitor for an object?

A

Event name
Event type
Array

112
Q

Which method can be used to create a new instance of http.Server in Node.js?

A

http.createServer()

113
Q

Which method can be used to read a file asynchronously in Node.js?

A

fs.readFile()

114
Q

Which module can be used in Node.js to emit and handle events?

A

The ‘events’ module

115
Q

Which Node.js command can be used to run a JavaScript file named script.js?

A

node script.js

116
Q

Which npm command can be used to install the webpack library as a development dependency?

A

npm install webpack –save-dev

117
Q

Which Node.js command can be used to check the syntax of the code without execution?

A

node –check

118
Q

What are the three types of modules that can be included in a Node.js application?

A

Core
local
third-party modules

119
Q

Which core module can be used to work with the file system in Node.js?

A

The ‘fs’ module

120
Q

Which third-party module can be used to handle incoming HTTP requests in Node.js?

A

Express

121
Q

When following the semantic versioning spec, how should the version number of a package be updated in case of a patch release?

A

The third digit of the version number should be incremented. For example, 1.0.3 should be changed to 1.0.4.

122
Q

Which command allows checking if there are installed packages that are outdated?

A

npm outdated

123
Q

Which command can be used to update an npm package named ‘lodash’ that is installed locally?

A

npm update lodash

124
Q

What console API method can be used to test an assertion?

A

console.assert()

125
Q

What is a false negative?

A

The test instance failed due to a defect in the test, not the code being tested.

126
Q

In which testing approach is the internal structure of the application not known?

A

Black-box testing

127
Q

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);

A

val1 == val2;
!!val2;
val1 === Number(val2)

128
Q

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

A

const num = 1/ Number(‘true’)

129
Q

____ is a library with the ability to perform deep comparisons between two objects with the _.isEqual() method

A

lodash

130
Q

How any parameters are passed to a decorator function that is used to decorate a class method?

A

Three

131
Q

What is the first argument passed to a decorator function that is used to decorate a class method?

A

target

132
Q

What is the second argument passed to a decorator function that is used to decorate a class method?

A

name

133
Q

What is the third argument passed to a decorator function that is used to decorate a class method?

A

descriptor

134
Q

What values does the Promise state property have?

A

Pending
Rejected
Fulfilled

135
Q

What is the difference between slice and splice?

A

Slice returns a new array from the original
Splice adds/removes from the original

136
Q

What does the unshift() method do?

A

The unshift() method adds one or more elements to the beginning of an array and returns the new length of the array.

137
Q

What does the shift() method do?

A

The shift() method removes the first element from an array and returns that removed element. This method changes the length of the array.

138
Q

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);

A

path.dirname(file);
path.parse(file).dir;

139
Q

What are 3 ways to create Objects?

A

Object Literal
Object Constructor
Object.create

140
Q

For var x, how do you create a new object as a literal?

A

var x = {}

141
Q

For var x, how do you create a new object as constructor?

A

var x = new Object()

142
Q

For var x, how do you create a new object with .create?

A
var obj = {
name : "foo"
}
var x = Object.create(obj);
143
Q

What two ways can you call typeof?

A
typeof operand
typeof(operand)
144
Q

What is the output?

typeof (typeof 1)
A

“string”

145
Q

What is the output?

typeof !!(-1)
A

“boolean”

146
Q

What is the output?

typeof function(){}
A

“function”

147
Q

What is the output?

typeof new Date()
A

“object”

148
Q

What is the output?

typeof null
A

“object”

149
Q

What is the output?

Number(39)
A

39

150
Q

What is the output?

Number(undefined)
A

NaN

151
Q

What is the output?

Number('hello')
A

NaN

152
Q

What is the output?

Number(" 45 ")
A

45

153
Q

What is the output?

Number("\t")
A

0

154
Q

What is the output?

Number('3x')
A

NaN

155
Q

What is the output?

Number(null)
A

0

156
Q

What is the output?

Number(false)
A

0

157
Q

What is the output?

Number(true)
A

1

158
Q

What is the output?

Number([])
A

0

159
Q

What is the output?

Number(['33'])
A

33

160
Q

What is the output?

Number(['33', '32'])
A

NaN

161
Q

What is the output?

Boolean(2)
A

true

162
Q

What is the output?

Boolean({})
A

true

163
Q

What is the output?

Boolean([])
A

true

164
Q

What is the output?

Boolean('2')
A

true

165
Q

What is the output?

Boolean('')
A

false

166
Q

What is the output?

Boolean(null)
A

false

167
Q

What is the output?

Boolean(0)
A

false

168
Q

What is the output?

Boolean(undefined)
A

false

169
Q

What is the output?

Boolean(false)
A

false

170
Q

What is the output?

Boolean(NaN)
A

false

171
Q

What is the output?

Boolean(0n)
A

false

172
Q

What is the output?

Boolean(1324n)
A

true

173
Q

What is the output?

100 + 'world'
A

‘100world’

174
Q

What is the output?

'foo' + 100
A

‘foo100’

175
Q

What is the output?

100 + null + 30 + 'foo'
A

‘130foo’

176
Q

What is the output?

100 + 400 + undefined + 'foo'
A

‘NaNfoo’

177
Q

What is the output?

var x = {}
x+'foo'
A

“[object Object]foo”

178
Q

What is the output?

100 == '100'
A

true

179
Q

What is the output?

100 === '100'
A

false

180
Q

What is the output?

true == 'true'
A

false

181
Q

What is the output?

NaN === NaN
A

false

182
Q

What is the output?

-0 === 0
A

true

183
Q

What is the output?

Object.is(-0, 0)
A

false

184
Q

What is the output?

s()
var s = function{
console.log('hi);
}
A

uncaught error s is not a function

185
Q

What is the output?

"use strict";
x = 3.14;
A

uncaught syntax error: x is not defined

186
Q

What is the output?

"use strict";
var x = 3.14;
delete x;
A

uncaught syntax error: delete of an unqualified identifier in strict mode

187
Q

What is the output?

"use strict";
function x (p1, p1){};
A

uncaught syntax error: duplicate parameter name not allowed in this context

188
Q

What is the output?

var func = new Function('a', 'b', 'return a*b');
func(4,3);
A

12

189
Q

What is the output?

[...'hello']
A

[‘h’,’e’,’l’,’l’,’o’]

190
Q

What is the output?

var employee = {fName: 'hi', lName : 'hello'};
var {fName, lName} = employee
fName;
lName;
A

hi
hello

191
Q

What is the output?

function outer(){
   var counter = 0;
   return function inner(){
       counter += 1
      return counter
}}

var counter = outer();
counter();
counter();
counter();
A

3

192
Q

What does location.assign do?

A

loads a new document

193
Q

What does Navigator.online do

A

returns true / false on if connected to internet

194
Q

What way is this Object being instantiated?

var x = {}
var detail = {
                name: "nikhil"
}
A

Object literal

195
Q

What way is this Object being instantiated?

var x = new Object()
x.name = "dude"
console.log(x)
A

Object constructor

196
Q

What way is this Object being instantiated?

var obj = {
          name: "dude"
			 }
var newObj = Object.create(obj)
A

Object.create() method

197
Q

What is the output?

typeof NaN

A

Number

198
Q

What is the output?

typeof 0
A

Number

199
Q

What is the output?

typeof “true”

A

String

200
Q

What is the output?

var x
typeof x
A

undefined

201
Q

What is the output?

typeof null
A

object

202
Q

What is the output?

typeof {}
A

object

203
Q

What is the output?

typeof !!(1)
A

Boolean

204
Q

What is the output?

typeof function () { }
A

function

205
Q

What is the output?

typeof new Date()
A

Object

206
Q

What is the output?

String(undefined)
A

‘undefined’

207
Q

What is the output?

String(true)
A

‘true’

208
Q

What is the output?

Number(Symbol())
A

TypeError thrown, as symbols cannot be converted to a Number

209
Q

What is the output?

String([])
A

’’

210
Q

What is the output?

String({})
A

[object Object]

211
Q

What is the output?

String([a:1,b:2])
A

[object Object]

212
Q

What is the output?

String([5,10,15])
A

5,10,15

213
Q

What is the output?

String(null)
A

‘null’

214
Q

What is the output?

String(Symbol('hello'))
A

Symbol(‘hello’)

215
Q

What is the output?

Number(null)
A

0

216
Q

What is the output?

Number(undefined)
A

NaN

217
Q

What is the output?

Number('hello')
A

NaN

218
Q

What is the output?

Number([])
A

0

219
Q

What is the output?

Number([33, 33])
A

NaN

220
Q

What is the output?

Number(['52'])
A

52

221
Q

What is the output?

Boolean('')
A

false

222
Q

What is the output?

Boolean(' ')
A

true

223
Q

What is the output?

Boolean(undefined)
A

false

224
Q

What is the output?

Boolean(null)
A

false

225
Q

What is the output?

Boolean(NaN)
A

false

226
Q

What is the output?

NaN == NaN
A

false

227
Q

What is the output?

NaN === NaN
A

false

228
Q

What is the output?

- 0 == 0
A

true

229
Q

What is the output?

- 0 === 0
A

true

230
Q

What is the output?

[] === []
A

false

231
Q

What is the output?

[] == []
A

false

232
Q

What is the output?

Object.is(100, "100")
A

false

233
Q

What is the output?

var x = 10
console.log(x++)
A

10

234
Q

What is the output?

var x = 10
x++
console.log(x);
A

11

235
Q

What is the output?

var x = []
var y = x
x === y
A

true

236
Q

What is the output?

"Hello" + "World" + "16546542"
A

‘HelloWorld16546542’

237
Q

What is the output?

100 + "world"
A

‘100world’

238
Q

What is the output?

100 + null + 20 + "world"
A

‘120world’

239
Q

What is the output?

true + 1 + "hey"
A

‘2hey’

240
Q

What is the output?

undefined + 2
A

NaN

241
Q

What is the output?

null + 2
A

2

242
Q

What is the output?

100 + 200 + undefined + "hey"
A

NaNhey

243
Q

What is the output?

undefined + 2 + 'no'
A

NaNno

244
Q

What is the output?

JSON.parse("'str'")
A
Uncaught SyntaxError: Unexpected token '''
"'str'" is not valid JSON
    at JSON.parse (<anonymous>)
    at <anonymous>:1:6
245
Q

What is the output?

JSON.parse("str")
A
Uncaught SyntaxError: Unexpected token 's',
"str" is not valid JSON
    at JSON.parse (<anonymous>)
    at <anonymous>:1:6
246
Q

What is the output?

JSON.parse('str')
A
Uncaught SyntaxError: Unexpected token 's',
"str" is not valid JSON
    at JSON.parse (<anonymous>)
    at <anonymous>:1:6
247
Q

What is the output?

'"'
JSON.parse('"str"')
A

‘str’

248
Q

What command is used to install pre-reqs for this code?

const fs = require('fs')
const _ = require('lodash')
A

npm i lodash

npm install lodash

note: fs comes with Node.js so this is redundant

249
Q

What is a black box test?

A

A test that only considers the external behavior of the system

250
Q

What is a white box test?

A

A method used to test a software taking into consideration its internal functioning

251
Q

What javascript statement can be used to insert a ‘newelementdiv’ after ‘markerelement’?

A

document.body.insertBefore(newelementdiv, markerElement.nextSibling)

252
Q

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
A

Scope Pane

253
Q

In package.json, what versions can be installed with ~

~1.2.3

A

releases from 1.2.3 to <1.3.0.

254
Q

In package.json, what version will be installed with ~2.2.0

  • 2.2.3
  • 3.0.1
  • 2.2.1
  • 2.3.1
A

2.2.3

255
Q

In package.json, what versions can be installed with ^

^1.2.3

A

releases from 1.2.3 to <2.0.0

256
Q

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
A

node inspect app.js, next

257
Q

How many arguments does the reduce() method take? What do the argument(s) do?

A

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
Q

What is the output?

Number.isNaN(‘hello’)

A

false

this is false because Number.isNan method only checks if the value is equal to NaN

259
Q

What is the output?

isNaN(‘hello’)

A

true

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
Q

What is the output?

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

console.log(bool == 5);
A

false

261
Q

What are 3 ways to loop through arrays?

A
for(let i = 0; i < customers.length; i ++) {}
 for(const index in customers) {}
 customers.forEach(customer =>{})
262
Q
A
263
Q

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]);
A

10

264
Q

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]);
A

3

265
Q

What is the output?

const bool = false;
const str = '5';

console.log(bool & str);
console.log(bool && str);
A
0
false
266
Q

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
A
  • Testing can be automated
  • The focus is on testing structures, objects and functions
  • Testing is mostly performed by software developers
267
Q

In nodeJS, how do you write a body JSON?

A

response.write(jsonStr);