Server Side JavaScript Flashcards
Node.js command to enable the V8 Inspector for debugging
node —inspect
Node.js start command
npm start
Node.js jest test command
npm run test or npm test
Exporting modules in Node.js
Functions: module.exports.functionName or exports.functionName
Classes: default export syntax, new value is added to exports object, like module.exports = Class
Set breakpoint on specific line of code
setBreakpoint(line) or sb(line)
Watch specific variable
watch(‘variable’)
Step to the next line of code
next command
Continue code execution
cont command
Step into a function call
step command
To access variables in any file in the application, variables should be declared using what?
Declared as part of the global object, like global.variable
Node.js versioning
^ 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
In Node.js, which method is used to emit an event?
eventEmitter.emit()
In Node.js, which method can be used to attach an event handler to handle the specified event?
eventEmitter.on() or eventEmitter.addListener()
Which methods can be used to retrieve an objects file path?
path.dirname(file) or path.parse(file).dir
Which method is used to calculate the actual path when it contains relative specifiers (such as ., .., or //)?
path.normalize()