Node Ecosystem, TDD, CI/CD
1. Why would you want to run JavaScript code outside of a browser?
Javascript is a greawt programing language, but it can’t be run outside of a browser enviourment untill the node.js was created. Running JS outside of browser could let you use the same web-UI language to build up the backend server, deal with database and create RESTful API.
2. What is the difference between a module and a package?
A JS module is normally a signle file, has limited features. While a package is a folder contains many modules and is a collection of different features.
3. What does the node package manager do?
This CLI tool find, install, update and uninstall Node packages.
4. Provide code snippets showing 3 different ways to export a function from a node module
// Exporting individual features
export let name1, name2, …, nameN; // also var, const
export let name1 = …, name2 = …, …, nameN; // also var, const
export function functionName(){...}
export class ClassName {...}
// Export list
export { name1, name2, …, nameN };
// Renaming exports
export { variable1 as name1, variable2 as name2, …, nameN };
// Exporting destructured assignments with renaming
export const { name1, name2: bar } = o;
// Default exports
export default expression;
export default function (…) { … } // also class, function*
export default function name1(…) { … } // also class, function*
export { name1 as default, … };
// Aggregating modules
export * from …; // does not set the default export
export * as name1 from …; // Draft ECMAScript® 2O21
export { name1, name2, …, nameN } from …;
export { import1 as name1, import2 as name2, …, nameN } from …;
export { default } from …;
reference: MDN (https://developer.mozilla.org/en-US/docs/web/javascript/reference/statements/export)