Node Flashcards
What is Node.js?
a JavaScript runtime that is asynchronous and event driven.
Environment that lets us execute JavaScript code that doesn’t use a browser
What can Node.js be used for?
It can be used to write command line tools and server-side scripting, making JavaScript to be the language for both server and client side
What is a REPL?
Read-Eval-Print-Loop. Takes user-made input and returns it one line at a time
When was Node.js created?
May 27, 2009
What back end languages have heard of?`
Python, JavaScript, Java, Ruby, C#, C++, PHP
What is the ‘process’ object in a Node.js program?
Its a global that provides info about and control over the current Node.js process
How do you access the ‘process’ object in a Node.js program?
Use the process variable
What is the data type of ‘process.argv’ in Node.js?
Returns an array
What is a JavaScript module?
It is a single ‘.js’ file meant to separate out some functionality
What values are passed into a Node.js module’s local scope?
‘module,’ ‘require,’ ‘exports,’ ‘__dirname,’ ‘__filename’
Give 2 examples of truly global variables in a Node.js program.
- global
- console
- setTimeout()
- clearInterval()
What is the purpose of ‘module.exports’ in a Node.js module?
Allows data types to be returned from a module called by using ‘require()’
How do you import functionality into a Node.js module from another Node.js module?
the require() function.
The source module contains the desired functionality within its code, followed by exports.name = name
The calling module contains the name, using a require()
What is a directory?
A file that lists locations to other files
What is a relative file path?
Set of directions from the current directory to its destination
What is an absolute file path?
A path to a file that has the entire path shown, from its root element to its final destination
What module does Node.js include for manipulating the file system?
‘fs.’ module
What method is available in the Node.js ‘fs’ module for writing data to a file?
fs.writeFile()