Explain the purpose of the package.json file and node_modules directory.
Given multiple choices, identify the difference between npm’s package.json and package-lock.json files.
Use npm –version to check what version is currently installed and use npm to update itself to the latest version.
Use npm init to create a new package and npm install to add a package as a dependency. Then use require to import the module and utilize it in a JavaScript file.
Given an existing GitHub repository, clone the repo and use npm to install it’s dependencies.
Define a constructor function using ES5 syntax.
prototype
of a constructor function.Define a static method on the prototype
of a constructor function.
function Book() { // constructor function ES5 (looks exactly like a regular function)
}
Book.prototype.read = function() { // instance method
}
Book.readAllBooks = function() { // static method
}
class
using ES6 syntax.class Book {
constructor() {
}
read() {
}
static readAllBooks() {
}
}
Book.prototype.anotherRead = function() { // instance method
}
const objectKeys = Object.keys;
Define an instance method
on a class (ES6).
Define a static method
on a class (ES6).
Instantiate an instance of a class using the new
keyword.
extends
syntax for an ES6 class.class Book {
constructor(name, author) {
}
read() {
}
}
class Magazine extends Book {
flipThrough() {
}
read() {
// overwriting Book's read method
}
}
const mag = new Magazine();
mag.read();
const book = new Book();
book.flipThrough();
Utilize the super
keyword in a child class to inherit from a parent class.
Utilize module.exports
and require
to import and export functions and class from one file to another.
class Book {
}
class Magazine {
}
const obj = {
Book,
Magazine
}
// module.exports = obj;
module.exports = Book;
What are the three pillars of object-oriented programming? What is each pillar’s definition?
The SOLID principles - What does each letter stand for? - We talked about the S and L in more depth; know how to apply them and what they mean for us in JavaScript
How to apply the Law of Demeter
module.exports = ClassName
, module.exports = { ClassName }
, or exports.ClassName = ClassName
for exporting. Know the differences and how to use each.const ClassName = require('./file/path')
or const { ClassName } = require('./file/path')
for importing. Know the differences and how to use each.