Node.JS Flashcards
CodeWithMosh (93 cards)
Node is a framework?
TRUE / FALSE
FALSE
Node is a run time environment for executing JS code
Node works Synchronise or Asynchronise
Asynchronise
Node is good for?
- CPU intensive sites
- I/O disk network access apps
I/O disk network access apps
how to run a JS file in node?
node “name of file”
how to start node in terminal?
node
how to end node in terminal?
control+c twice
in node there is no window object
TRUE / FLASE
TRUE
window.console.log();
Write the above for Node
global.console.log
there is no window object in NODE instead we use the keyword _______
global
var message = ' '; console.log(global.message); //returns in NODE?
undefined
every file in node is considered a _____
module
to load a module we use the ______ keyword
require
require(‘./logger’);
convert to new ES6 syntax
import ‘./logger’;
what we used to indicated current folder
./
period slash
when using node as best practice what should be changed?
var logger = require(‘./logger’);
console. log(logger);
logger. log(“hello”);
var to const
loading module when importing use const so it does not change
variables and functions are scoped to the ______
modules
what is not valid and why?
exports.log = log;
module.exports.log = log;
exports = log;
//this exports is a reference to module.exports function
exports = log;
The path module provides utilities for working with file and directory paths. It can be accessed using:
const path = _________(‘path’);
require
The ________ module provides utilities for working with file and directory paths.
path
The _________ module provides a number of operating system-related utility methods.
OS
The os module provides a number of operating system-related utility methods. It can be accessed using:
const os = ________
const os = require(‘os’);
The ______ module provides an API for interacting with the file system in a manner closely modeled around standard POSIX functions
fs
filesystem
const fs = ________
const fs = require(‘fs’);
when using File System Module there are Asynchronous and Synchronous methods, what should we generally use?
Asynchronous or non blocking