Server Side JavaScript Flashcards

1
Q

Node.js command to enable the V8 Inspector for debugging

A

node —inspect

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

Node.js start command

A

npm start

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

Node.js jest test command

A

npm run test or npm test

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

Exporting modules in Node.js

A

Functions: module.exports.functionName or exports.functionName

Classes: default export syntax, new value is added to exports object, like module.exports = Class

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

Set breakpoint on specific line of code

A

setBreakpoint(line) or sb(line)

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

Watch specific variable

A

watch(‘variable’)

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

Step to the next line of code

A

next command

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

Continue code execution

A

cont command

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

Step into a function call

A

step command

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

To access variables in any file in the application, variables should be declared using what?

A

Declared as part of the global object, like global.variable

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

Node.js versioning

A

^ can be used to allow for version numbers that are in the same major range; comparison operators; ~ can be used for minor range; x allows for things that begin with the number you use

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

In Node.js, which method is used to emit an event?

A

eventEmitter.emit()

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

In Node.js, which method can be used to attach an event handler to handle the specified event?

A

eventEmitter.on() or eventEmitter.addListener()

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

Which methods can be used to retrieve an objects file path?

A

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

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

Which method is used to calculate the actual path when it contains relative specifiers (such as ., .., or //)?

A

path.normalize()

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

Which environment variable is used to de the application mode that determines which features should be enabled or disabled?

A

NODE_ENV

17
Q

In Node.js code, how can the value of NODE_ENV be accessed?

A

process.ENV.NODE_ENV

18
Q

When using the Linux or Mac OS, which command is used to set the value of the NODE_ENV variable?

A

export NODE_ENV=production

19
Q

In the Windows OS, which command can be used to change the NODE_ENV variable?

A

$env:NODE_ENV = ‘production’

20
Q

In Node.js, which flag can be used to evaluate the passed argument as JavaScript?

A

node -e “block of code”

21
Q

In Node.js, which flag checked the syntax of the code without executing it?

A

node -c “black of code”

22
Q

Which Node.js command installs a package?

A

npm i

23
Q

In Node.js, which module can be used to create a server?

A

‘http’ or ‘https’

24
Q

In Node.js, which function can be used to handle any incoming server requests?

A

createServer()

25
Q

Which methods are available to send a server response?

A

writeHead(), write(), and end()