Node Flashcards
pwd
print the current directory you in
where am I
echo
print content
console.log
touch
access time of the last edit time of the file
ls ‘xxx’
list directory contents
xxx: target directory
mkdir
create directory
mv
rename directory or file
rm
delete file only or use -r
cp
copy files or directories
rmdir
delete directory
What is a CLI?
command line interface
What is a GUI?
graphacial user interface
man
an interface to the system reference manuals
cat
concatenate files and print on the standard output
print the content of files
ls
list directory contents
What is Node.js?
Node.js 是能够在服务器端运行JavaScript 的开放源代码、跨平台执行环境。
What can Node.js be used for?
It is used for server-side programming, and primarily deployed for non-blocking, event-driven servers, such as traditional web sites and back-end API services, but was originally designed with real-time, push-based architectures in mind.
What is a REPL?
Read–eval–print loop)
“读取-求值-输出”循环,也被称做交互式顶层构件,是一个简单的,交互式的编程环境。这个词常常用于指代一个Lisp的交互式开发环境,也能指代命令行的模式。
What is the process object in a Node.js program?
data model of
How do you access the process object in a Node.js program?
just reference it
What is the data type of process.argv in Node.js?
array of strings
What is a JavaScript module?
module is the file with code
What values are passed into a Node.js module’s local scope
exports, require, module, __filename, __dirname
Give two examples of truly global variables in a Node.js program.
process, global
What is the purpose of module.exports in a Node.js module?
make it available to other modual
How do you import functionality into a Node.js module from another Node.js module?
call require with ()
require here is a reference (or a copy) of module.export.
What is the JavaScript Event Loop?
the event loop is the part of a JS runtime environment, that pushes asynchronous callback onto the callstack when callstack is clear
What is different between “blocking” and “non-blocking” with respect to how code is executed?
Blocking refers to operations that block further execution until that operation finishes while non-blocking refers to code that doesn’t block execution.
block (synchronous): this code will processed first , after it processed , rest code can be executed (ex: loop)
non-block (asynchronous): this code will processed, while it is processing , rest code can be executed too. (ex: HTTP request AJAX)
What is a directory?
list of files
What is a relative file path?
get from where you are to where you want to go
What is an absolute file path?
location of file from root directory
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
Are file operations using the fs module synchronous or asynchronous?
What is a client?
a program send request to server
What is a server?
a server send request back to user
Which HTTP method does a browser issue to a web server when you visit a URL?
GET
What is on the first line of an HTTP request message?
GET request-target(the thing you ask server for, if it’s / means give me whatever you have) HTTP/1.1 (format)
curl
just like httpie bur less functional , build in every computer. curl=see url
What is on the first line of an HTTP response message?
protocol message , code, status
What are HTTP headers?
extra info, just like head of html elements
Is a body required for a valid HTTP message?
no
domain name system
a bunch of servers that loop up IP address for domains, they also remember them for a while (like a phone book, when you got the URL ex.amazon.com, it will look for the IP of this website)
nc
make internet connect and catch all the stuff
what is behind the webpage url(domain name)
ip address. each website have different ip addresses
http port?
Default in http is 80
in https is 443
(drive to a restaurant , window you can order and perform actions)
What is NPM
website, registration list, cml
Registration have pacgages you can download by using cml
How can you create a package.json with npm?
npm init –yes
What is a dependency and how to you add one to a package?
dependency: modules from npm
how to add: npm install xxx
What happens when you add a dependency to a package with npm?
the package.json is updated with the new dependency
and the package is downloaded from the npm registry to node_modules
What is a package?
modules create by others and published on npm
Which objects does an Express application pass to your middleware to manage the request/response lifecycle of the server?
req, res
How do you mount a middleware with an Express application?
use()
address().port
shows the port number
What is the appropriate Content-Type header for HTTP messages that contain JSON in their bodies?
application/json
What does the express.json() middleware do and when would you need it?
app.delete(‘/api/grades/:id’, (req, res) =>{}
:id is a placeholder
What are some advantages of learning a relational database?
What is PostgreSQL and what are some alternative relational databases?
widely use
What is one way to see if PostgreSQL is running?
sudo service postgresql status
What is a database schema?
schema define structure
What is a database schema?
schema define structure of datas
What is a table?
list of rows have same attribute
What is a row?
the data