\documentclass[10pt,a4paper]{article} % Packages \usepackage{fancyhdr} % For header and footer \usepackage{multicol} % Allows multicols in tables \usepackage{tabularx} % Intelligent column widths \usepackage{tabulary} % Used in header and footer \usepackage{hhline} % Border under tables \usepackage{graphicx} % For images \usepackage{xcolor} % For hex colours %\usepackage[utf8x]{inputenc} % For unicode character support \usepackage[T1]{fontenc} % Without this we get weird character replacements \usepackage{colortbl} % For coloured tables \usepackage{setspace} % For line height \usepackage{lastpage} % Needed for total page number \usepackage{seqsplit} % Splits long words. %\usepackage{opensans} % Can't make this work so far. Shame. Would be lovely. \usepackage[normalem]{ulem} % For underlining links % Most of the following are not required for the majority % of cheat sheets but are needed for some symbol support. \usepackage{amsmath} % Symbols \usepackage{MnSymbol} % Symbols \usepackage{wasysym} % Symbols %\usepackage[english,german,french,spanish,italian]{babel} % Languages % Document Info \author{HoshiYouta} \pdfinfo{ /Title (pw.pdf) /Creator (Cheatography) /Author (HoshiYouta) /Subject (PW Cheat Sheet) } % Lengths and widths \addtolength{\textwidth}{6cm} \addtolength{\textheight}{-1cm} \addtolength{\hoffset}{-3cm} \addtolength{\voffset}{-2cm} \setlength{\tabcolsep}{0.2cm} % Space between columns \setlength{\headsep}{-12pt} % Reduce space between header and content \setlength{\headheight}{85pt} % If less, LaTeX automatically increases it \renewcommand{\footrulewidth}{0pt} % Remove footer line \renewcommand{\headrulewidth}{0pt} % Remove header line \renewcommand{\seqinsert}{\ifmmode\allowbreak\else\-\fi} % Hyphens in seqsplit % This two commands together give roughly % the right line height in the tables \renewcommand{\arraystretch}{1.3} \onehalfspacing % Commands \newcommand{\SetRowColor}[1]{\noalign{\gdef\RowColorName{#1}}\rowcolor{\RowColorName}} % Shortcut for row colour \newcommand{\mymulticolumn}[3]{\multicolumn{#1}{>{\columncolor{\RowColorName}}#2}{#3}} % For coloured multi-cols \newcolumntype{x}[1]{>{\raggedright}p{#1}} % New column types for ragged-right paragraph columns \newcommand{\tn}{\tabularnewline} % Required as custom column type in use % Font and Colours \definecolor{HeadBackground}{HTML}{333333} \definecolor{FootBackground}{HTML}{666666} \definecolor{TextColor}{HTML}{333333} \definecolor{DarkBackground}{HTML}{A3A3A3} \definecolor{LightBackground}{HTML}{F3F3F3} \renewcommand{\familydefault}{\sfdefault} \color{TextColor} % Header and Footer \pagestyle{fancy} \fancyhead{} % Set header to blank \fancyfoot{} % Set footer to blank \fancyhead[L]{ \noindent \begin{multicols}{3} \begin{tabulary}{5.8cm}{C} \SetRowColor{DarkBackground} \vspace{-7pt} {\parbox{\dimexpr\textwidth-2\fboxsep\relax}{\noindent \hspace*{-6pt}\includegraphics[width=5.8cm]{/web/www.cheatography.com/public/images/cheatography_logo.pdf}} } \end{tabulary} \columnbreak \begin{tabulary}{11cm}{L} \vspace{-2pt}\large{\bf{\textcolor{DarkBackground}{\textrm{PW Cheat Sheet}}}} \\ \normalsize{by \textcolor{DarkBackground}{HoshiYouta} via \textcolor{DarkBackground}{\uline{cheatography.com/211312/cs/45753/}}} \end{tabulary} \end{multicols}} \fancyfoot[L]{ \footnotesize \noindent \begin{multicols}{3} \begin{tabulary}{5.8cm}{LL} \SetRowColor{FootBackground} \mymulticolumn{2}{p{5.377cm}}{\bf\textcolor{white}{Cheatographer}} \\ \vspace{-2pt}HoshiYouta \\ \uline{cheatography.com/hoshiyouta} \\ \end{tabulary} \vfill \columnbreak \begin{tabulary}{5.8cm}{L} \SetRowColor{FootBackground} \mymulticolumn{1}{p{5.377cm}}{\bf\textcolor{white}{Cheat Sheet}} \\ \vspace{-2pt}Published 24th February, 2025.\\ Updated 24th February, 2025.\\ Page {\thepage} of \pageref{LastPage}. \end{tabulary} \vfill \columnbreak \begin{tabulary}{5.8cm}{L} \SetRowColor{FootBackground} \mymulticolumn{1}{p{5.377cm}}{\bf\textcolor{white}{Sponsor}} \\ \SetRowColor{white} \vspace{-5pt} %\includegraphics[width=48px,height=48px]{dave.jpeg} Measure your website readability!\\ www.readability-score.com \end{tabulary} \end{multicols}} \begin{document} \raggedright \raggedcolumns % Set font size to small. Switch to any value % from this page to resize cheat sheet text: % www.emerson.emory.edu/services/latex/latex_169.html \footnotesize % Small font. \begin{multicols*}{4} \begin{tabularx}{3.833cm}{x{1.0299 cm} x{2.4031 cm} } \SetRowColor{DarkBackground} \mymulticolumn{2}{x{3.833cm}}{\bf\textcolor{white}{Map}} \tn % Row 0 \SetRowColor{LightBackground} Map() & A JavaScript object that stores key-value pairs, where keys can be any type of data, and values can be any data type. \tn % Row Count 5 (+ 5) % Row 1 \SetRowColor{white} set(key, value) & Adds a new key-value pair to the Map. If the key already exists, it updates the value. \tn % Row Count 9 (+ 4) % Row 2 \SetRowColor{LightBackground} get(key) & Retrieves the value associated with the key from the Map. If the key doesn't exist, returns undefined. \tn % Row Count 13 (+ 4) % Row 3 \SetRowColor{white} has(key) & Checks if a key exists in the Map. Returns true or false. \tn % Row Count 16 (+ 3) % Row 4 \SetRowColor{LightBackground} delete(key) & Removes a key-value pair from the Map. \tn % Row Count 18 (+ 2) % Row 5 \SetRowColor{white} clear() & Removes all key-value pairs from the Map. \tn % Row Count 20 (+ 2) % Row 6 \SetRowColor{LightBackground} \seqsplit{forEach(callback)} & Iterates over each key-value pair in the Map and executes a provided function. \tn % Row Count 23 (+ 3) \hhline{>{\arrayrulecolor{DarkBackground}}--} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{3.833cm}{x{0.92691 cm} x{2.50609 cm} } \SetRowColor{DarkBackground} \mymulticolumn{2}{x{3.833cm}}{\bf\textcolor{white}{General}} \tn % Row 0 \SetRowColor{LightBackground} \seqsplit{console.log()} & Outputs a message to the console, commonly used for debugging. \tn % Row Count 3 (+ 3) % Row 1 \SetRowColor{white} let, const, var & Variable declaration keywords: let (block-scoped), const (block-scoped and immutable), var (function-scoped). \tn % Row Count 7 (+ 4) % Row 2 \SetRowColor{LightBackground} Promises & Represents a value that may be available in the future. It is used for handling asynchronous operations. \tn % Row Count 11 (+ 4) % Row 3 \SetRowColor{white} \seqsplit{async/await} & Used to simplify asynchronous code. await waits for a promise to resolve, and async makes a function asynchronous. \tn % Row Count 15 (+ 4) \hhline{>{\arrayrulecolor{DarkBackground}}--} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{3.833cm}{x{1.68217 cm} x{1.75083 cm} } \SetRowColor{DarkBackground} \mymulticolumn{2}{x{3.833cm}}{\bf\textcolor{white}{Teorico}} \tn % Row 0 \SetRowColor{LightBackground} DOM (Document Object Model) & The structure that represents the HTML document as a tree of nodes, allowing dynamic manipulation. \tn % Row Count 5 (+ 5) % Row 1 \SetRowColor{white} AJAX (Asynchronous JavaScript and XML) & Technique for making asynchronous HTTP requests to fetch data without refreshing the page. \tn % Row Count 10 (+ 5) % Row 2 \SetRowColor{LightBackground} JSON (JavaScript Object Notation) & Lightweight data-interchange format that's easy for humans to read and write, and for machines to parse and generate. \tn % Row Count 16 (+ 6) % Row 3 \SetRowColor{white} RESTful APIs & Design principles for building web services that are stateless and use HTTP methods for CRUD operations (GET, POST, PUT, DELETE). \tn % Row Count 23 (+ 7) % Row 4 \SetRowColor{LightBackground} CSS Flexbox & Layout model that allows for responsive and flexible design, aligning elements in rows or columns. \tn % Row Count 28 (+ 5) % Row 5 \SetRowColor{white} CSS Grid & 2D layout system for creating grid-based layouts with rows and columns. \tn % Row Count 32 (+ 4) \end{tabularx} \par\addvspace{1.3em} \vfill \columnbreak \begin{tabularx}{3.833cm}{x{1.68217 cm} x{1.75083 cm} } \SetRowColor{DarkBackground} \mymulticolumn{2}{x{3.833cm}}{\bf\textcolor{white}{Teorico (cont)}} \tn % Row 6 \SetRowColor{LightBackground} CORS (Cross-Origin Resource Sharing) & A mechanism that allows restricted resources on a web page to be requested from another domain. \tn % Row Count 5 (+ 5) \hhline{>{\arrayrulecolor{DarkBackground}}--} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{3.833cm}{x{1.3732 cm} x{2.0598 cm} } \SetRowColor{DarkBackground} \mymulticolumn{2}{x{3.833cm}}{\bf\textcolor{white}{Express}} \tn % Row 0 \SetRowColor{LightBackground} express() & The function used to create an instance of an Express application. \tn % Row Count 3 (+ 3) % Row 1 \SetRowColor{white} \seqsplit{app.listen(port)} & Starts the Express server and listens on a specified port. For example: app.listen(3000) to listen on port 3000. \tn % Row Count 8 (+ 5) % Row 2 \SetRowColor{LightBackground} app.get(route, callback) & Defines a route handler for GET requests. For example: app.get('/', (req, res) =\textgreater{} res.send('Hello World')) \tn % Row Count 13 (+ 5) % Row 3 \SetRowColor{white} app.post(route, callback) & Defines a route handler for POST requests. For example: app.post('/submit', (req, res) =\textgreater{} res.send('Data received')) \tn % Row Count 18 (+ 5) % Row 4 \SetRowColor{LightBackground} app.put(route, callback) & Defines a route handler for PUT requests. Typically used for updating data. \tn % Row Count 22 (+ 4) % Row 5 \SetRowColor{white} \seqsplit{app.delete(route}, callback) & Defines a route handler for DELETE requests. Usually used to remove resources. \tn % Row Count 26 (+ 4) % Row 6 \SetRowColor{LightBackground} \seqsplit{app.use(middleware)} & Adds middleware to the Express app. Middleware functions execute during the lifecycle of a request. For example: app.use(express.json()) to parse JSON in request bodies. \tn % Row Count 34 (+ 8) \end{tabularx} \par\addvspace{1.3em} \vfill \columnbreak \begin{tabularx}{3.833cm}{x{1.3732 cm} x{2.0598 cm} } \SetRowColor{DarkBackground} \mymulticolumn{2}{x{3.833cm}}{\bf\textcolor{white}{Express (cont)}} \tn % Row 7 \SetRowColor{LightBackground} res.send() & Sends a response to the client. Can send various types of data such as strings, objects, or arrays. \tn % Row Count 5 (+ 5) % Row 8 \SetRowColor{white} res.json() & Sends a JSON response. Converts an object or array to JSON format. \tn % Row Count 8 (+ 3) \hhline{>{\arrayrulecolor{DarkBackground}}--} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{3.833cm}{x{1.7165 cm} x{1.7165 cm} } \SetRowColor{DarkBackground} \mymulticolumn{2}{x{3.833cm}}{\bf\textcolor{white}{NodeJs}} \tn % Row 0 \SetRowColor{LightBackground} require() & Imports modules, JSON, or local files into your Node.js application. \tn % Row Count 4 (+ 4) % Row 1 \SetRowColor{white} fs module & Provides an API for interacting with the file system, allowing you to read, write, and modify files. \tn % Row Count 9 (+ 5) % Row 2 \SetRowColor{LightBackground} module.exports & Defines what a module exports so that other files can use it. \tn % Row Count 13 (+ 4) % Row 3 \SetRowColor{white} fs.readFile(path, encoding, callback) & Asynchronously reads the contents of a file. The callback receives two arguments: an error (if any) and the data. \tn % Row Count 19 (+ 6) % Row 4 \SetRowColor{LightBackground} fs.writeFile(path, data, encoding, callback) & Asynchronously writes data to a file, replacing the file if it already exists. The callback handles error (if any). \tn % Row Count 25 (+ 6) % Row 5 \SetRowColor{white} fs.appendFile(path, data, encoding, callback) & Asynchronously appends data to a file. If the file does not exist, it is created. The callback handles error (if any). \tn % Row Count 31 (+ 6) \end{tabularx} \par\addvspace{1.3em} \vfill \columnbreak \begin{tabularx}{3.833cm}{x{1.7165 cm} x{1.7165 cm} } \SetRowColor{DarkBackground} \mymulticolumn{2}{x{3.833cm}}{\bf\textcolor{white}{NodeJs (cont)}} \tn % Row 6 \SetRowColor{LightBackground} fs.copyFile(src, dest, callback) & Asynchronously copies a file from src to dest. The callback handles error (if any). \tn % Row Count 5 (+ 5) \hhline{>{\arrayrulecolor{DarkBackground}}--} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{3.833cm}{x{1.27021 cm} x{2.16279 cm} } \SetRowColor{DarkBackground} \mymulticolumn{2}{x{3.833cm}}{\bf\textcolor{white}{Events}} \tn % Row 0 \SetRowColor{LightBackground} \seqsplit{addEventListener()} & Attaches an event handler to an element for a specific event. \tn % Row Count 3 (+ 3) % Row 1 \SetRowColor{white} \seqsplit{removeEventListener()} & Removes an event handler from an element. \tn % Row Count 5 (+ 2) % Row 2 \SetRowColor{LightBackground} event.target & Returns the element that triggered the event. \tn % Row Count 7 (+ 2) % Row 3 \SetRowColor{white} \seqsplit{event.preventDefault()} & Cancels the default behavior of an event (e.g., prevents form submission). \tn % Row Count 10 (+ 3) % Row 4 \SetRowColor{LightBackground} \seqsplit{event.stopPropagation()} & Stops the event from propagating up or down the DOM tree. \tn % Row Count 13 (+ 3) % Row 5 \SetRowColor{white} \seqsplit{DOMContentLoaded} & Fires when the HTML has been completely loaded, but before stylesheets, images, and subframes finish loading. \tn % Row Count 18 (+ 5) \hhline{>{\arrayrulecolor{DarkBackground}}--} \end{tabularx} \par\addvspace{1.3em} % That's all folks \end{multicols*} \end{document}