Show Menu
Cheatography

Bfasddsfdsfsdrfsedfds

Map

Map()
A JavaScript object that stores key-value pairs, where keys can be any type of data, and values can be any data type.
set(key, value)
Adds a new key-value pair to the Map. If the key already exists, it updates the value.
get(key)
Retrieves the value associated with the key from the Map. If the key doesn’t exist, returns undefined.
has(key)
Checks if a key exists in the Map. Returns true or false.
delete­(key)
Removes a key-value pair from the Map.
clear()
Removes all key-value pairs from the Map.
forEac­h(c­all­back)
Iterates over each key-value pair in the Map and executes a provided function.

General

consol­e.log()
Outputs a message to the console, commonly used for debugging.
let, const, var
Variable declar­ation keywords: let (block­-sc­oped), const (block­-scoped and immuta­ble), var (funct­ion­-sc­oped).
Promises
Represents a value that may be available in the future. It is used for handling asynch­ronous operat­ions.
async/­await
Used to simplify asynch­ronous code. await waits for a promise to resolve, and async makes a function asynch­ronous.
 

Teorico

DOM (Document Object Model)
The structure that represents the HTML document as a tree of nodes, allowing dynamic manipu­lation.
AJAX (Async­hronous JavaScript and XML)
Technique for making asynch­ronous HTTP requests to fetch data without refreshing the page.
JSON (JavaS­cript Object Notation)
Lightw­eight data-i­nte­rchange format that’s easy for humans to read and write, and for machines to parse and generate.
RESTful APIs
Design principles for building web services that are stateless and use HTTP methods for CRUD operations (GET, POST, PUT, DELETE).
CSS Flexbox
Layout model that allows for responsive and flexible design, aligning elements in rows or columns.
CSS Grid
2D layout system for creating grid-based layouts with rows and columns.
CORS (Cross­-Origin Resource Sharing)
A mechanism that allows restricted resources on a web page to be requested from another domain.
 

Express

express()
The function used to create an instance of an Express applic­ation.
app.li­ste­n(port)
Starts the Express server and listens on a specified port. For example: app.li­ste­n(3000) to listen on port 3000.
app.ge­t(r­oute, callback)
Defines a route handler for GET requests. For example: app.ge­t('/', (req, res) => res.se­nd(­'Hello World'))
app.po­st(­route, callback)
Defines a route handler for POST requests. For example: app.po­st(­'/s­ubmit', (req, res) => res.se­nd(­'Data receiv­ed'))
app.pu­t(r­oute, callback)
Defines a route handler for PUT requests. Typically used for updating data.
app.de­let­e(r­oute, callback)
Defines a route handler for DELETE requests. Usually used to remove resources.
app.us­e(m­idd­leware)
Adds middleware to the Express app. Middleware functions execute during the lifecycle of a request. For example: app.us­e(e­xpr­ess.js­on()) to parse JSON in request bodies.
res.send()
Sends a response to the client. Can send various types of data such as strings, objects, or arrays.
res.json()
Sends a JSON response. Converts an object or array to JSON format.
 

NodeJs

require()
Imports modules, JSON, or local files into your Node.js applic­ation.
fs module
Provides an API for intera­cting with the file system, allowing you to read, write, and modify files.
module.ex­ports
Defines what a module exports so that other files can use it.
fs.rea­dFi­le(­path, encoding, callback)
Asynch­ron­ously reads the contents of a file. The callback receives two arguments: an error (if any) and the data.
fs.wri­teF­ile­(path, data, encoding, callback)
Asynch­ron­ously writes data to a file, replacing the file if it already exists. The callback handles error (if any).
fs.app­end­Fil­e(path, data, encoding, callback)
Asynch­ron­ously appends data to a file. If the file does not exist, it is created. The callback handles error (if any).
fs.cop­yFi­le(src, dest, callback)
Asynch­ron­ously copies a file from src to dest. The callback handles error (if any).

Events

addEve­ntL­ist­ener()
Attaches an event handler to an element for a specific event.
remove­Eve­ntL­ist­ener()
Removes an event handler from an element.
event.t­arget
Returns the element that triggered the event.
event.p­re­ven­tDe­fault()
Cancels the default behavior of an event (e.g., prevents form submis­sion).
event.s­to­pPr­opa­gat­ion()
Stops the event from propag­ating up or down the DOM tree.
DOMCon­ten­tLoaded
Fires when the HTML has been completely loaded, but before styles­heets, images, and subframes finish loading.
 

Comments

No comments yet. Add yours below!

Add a Comment

Your Comment

Please enter your name.

    Please enter your email address

      Please enter your Comment.

          Related Cheat Sheets

          JavaScript Cheat Sheet
            Bootstrap Glyphicons Cheat Sheet by James Croft