\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{andrea\_25} \pdfinfo{ /Title (javascript.pdf) /Creator (Cheatography) /Author (andrea\_25) /Subject (JavaScript 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}{A3A30A} \definecolor{LightBackground}{HTML}{F9F9EF} \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{JavaScript Cheat Sheet}}}} \\ \normalsize{by \textcolor{DarkBackground}{andrea\_25} via \textcolor{DarkBackground}{\uline{cheatography.com/195327/cs/40888/}}} \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}andrea\_25 \\ \uline{cheatography.com/andrea-25} \\ \end{tabulary} \vfill \columnbreak \begin{tabulary}{5.8cm}{L} \SetRowColor{FootBackground} \mymulticolumn{1}{p{5.377cm}}{\bf\textcolor{white}{Cheat Sheet}} \\ \vspace{-2pt}Published 18th October, 2023.\\ Updated 18th October, 2023.\\ 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*}{3} \begin{tabularx}{5.377cm}{X} \SetRowColor{DarkBackground} \mymulticolumn{1}{x{5.377cm}}{\bf\textcolor{white}{Comments}} \tn % Row 0 \SetRowColor{LightBackground} \mymulticolumn{1}{x{5.377cm}}{`// this is a single line comment`} \tn % Row Count 1 (+ 1) % Row 1 \SetRowColor{white} \mymulticolumn{1}{x{5.377cm}}{`/* this is a multi-line comment */`} \tn % Row Count 2 (+ 1) \hhline{>{\arrayrulecolor{DarkBackground}}-} \SetRowColor{LightBackground} \mymulticolumn{1}{x{5.377cm}}{This code will be ignored. Comments are generally a bad idea, your code should be explicit enough as it is. \newline \{\{link="https://www.w3schools.com/js/js\_comments.asp"\}\}More info\{\{/link\}\}} \tn \hhline{>{\arrayrulecolor{DarkBackground}}-} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{5.377cm}{X} \SetRowColor{DarkBackground} \mymulticolumn{1}{x{5.377cm}}{\bf\textcolor{white}{Variable creation}} \tn % Row 0 \SetRowColor{LightBackground} \mymulticolumn{1}{x{5.377cm}}{`let variable = "some value";`} \tn % Row Count 1 (+ 1) % Row 1 \SetRowColor{white} \mymulticolumn{1}{x{5.377cm}}{`let num = 4;`} \tn % Row Count 2 (+ 1) % Row 2 \SetRowColor{LightBackground} \mymulticolumn{1}{x{5.377cm}}{`let isTrue = true;`} \tn % Row Count 3 (+ 1) \hhline{>{\arrayrulecolor{DarkBackground}}-} \SetRowColor{LightBackground} \mymulticolumn{1}{x{5.377cm}}{\{\{link="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/let"\}\}More info\{\{/link\}\}} \tn \hhline{>{\arrayrulecolor{DarkBackground}}-} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{5.377cm}{X} \SetRowColor{DarkBackground} \mymulticolumn{1}{x{5.377cm}}{\bf\textcolor{white}{Variable operations}} \tn % Row 0 \SetRowColor{LightBackground} \mymulticolumn{1}{x{5.377cm}}{`let x = 2;`} \tn % Row Count 1 (+ 1) % Row 1 \SetRowColor{white} \mymulticolumn{1}{x{5.377cm}}{`let y = 3;`} \tn % Row Count 2 (+ 1) % Row 2 \SetRowColor{LightBackground} \mymulticolumn{1}{x{5.377cm}}{`let z = x + y;`} \tn % Row Count 3 (+ 1) % Row 3 \SetRowColor{white} \mymulticolumn{1}{x{5.377cm}}{} \tn % Row Count 3 (+ 0) % Row 4 \SetRowColor{LightBackground} \mymulticolumn{1}{x{5.377cm}}{`let city = "Rome";`} \tn % Row Count 4 (+ 1) % Row 5 \SetRowColor{white} \mymulticolumn{1}{x{5.377cm}}{`let country = "Italy";`} \tn % Row Count 5 (+ 1) % Row 6 \SetRowColor{LightBackground} \mymulticolumn{1}{x{5.377cm}}{`let place = city + " " + country; // Rome Italy`} \tn % Row Count 6 (+ 1) \hhline{>{\arrayrulecolor{DarkBackground}}-} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{5.377cm}{X} \SetRowColor{DarkBackground} \mymulticolumn{1}{x{5.377cm}}{\bf\textcolor{white}{Variable data types}} \tn % Row 0 \SetRowColor{LightBackground} \mymulticolumn{1}{x{5.377cm}}{`let age = 92; // Number`} \tn % Row Count 1 (+ 1) % Row 1 \SetRowColor{white} \mymulticolumn{1}{x{5.377cm}}{`let name = "Tommaso"; // String`} \tn % Row Count 2 (+ 1) % Row 2 \SetRowColor{LightBackground} \mymulticolumn{1}{x{5.377cm}}{`let canCode = true; // Boolean`} \tn % Row Count 3 (+ 1) \hhline{>{\arrayrulecolor{DarkBackground}}-} \SetRowColor{LightBackground} \mymulticolumn{1}{x{5.377cm}}{\{\{link="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data\_structures"\}\}More info\{\{/link\}\}} \tn \hhline{>{\arrayrulecolor{DarkBackground}}-} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{5.377cm}{X} \SetRowColor{DarkBackground} \mymulticolumn{1}{x{5.377cm}}{\bf\textcolor{white}{Structure types}} \tn % Row 0 \SetRowColor{LightBackground} \mymulticolumn{1}{x{5.377cm}}{`let students = {[}"Salvatore", "Leonardo", "Antonella"{]}; // Array`} \tn % Row Count 2 (+ 2) % Row 1 \SetRowColor{white} \mymulticolumn{1}{x{5.377cm}}{let kate = \{ firstName: "Marianna", lastName: "Di Luna", age: 23, canCode: true, \}; // Object} \tn % Row Count 5 (+ 3) \hhline{>{\arrayrulecolor{DarkBackground}}-} \SetRowColor{LightBackground} \mymulticolumn{1}{x{5.377cm}}{\{\{link="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data\_structures"\}\}More info\{\{/link\}\}} \tn \hhline{>{\arrayrulecolor{DarkBackground}}-} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{5.377cm}{X} \SetRowColor{DarkBackground} \mymulticolumn{1}{x{5.377cm}}{\bf\textcolor{white}{Alert}} \tn % Row 0 \SetRowColor{LightBackground} \mymulticolumn{1}{x{5.377cm}}{`alert("this is an alert)";`} \tn % Row Count 1 (+ 1) % Row 1 \SetRowColor{white} \mymulticolumn{1}{x{5.377cm}}{`let name = "Jack";`} \tn % Row Count 2 (+ 1) % Row 2 \SetRowColor{LightBackground} \mymulticolumn{1}{x{5.377cm}}{`alert(name);`} \tn % Row Count 3 (+ 1) \hhline{>{\arrayrulecolor{DarkBackground}}-} \SetRowColor{LightBackground} \mymulticolumn{1}{x{5.377cm}}{\{\{link="https://developer.mozilla.org/en-US/docs/Web/API/Window/alert"\}\}More info\{\{/link\}\}} \tn \hhline{>{\arrayrulecolor{DarkBackground}}-} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{5.377cm}{X} \SetRowColor{DarkBackground} \mymulticolumn{1}{x{5.377cm}}{\bf\textcolor{white}{Prompt}} \tn % Row 0 \SetRowColor{LightBackground} \mymulticolumn{1}{x{5.377cm}}{`let firstName = prompt("What's your first name?");`} \tn % Row Count 2 (+ 2) % Row 1 \SetRowColor{white} \mymulticolumn{1}{x{5.377cm}}{`let lastName= prompt("What's your last name?");`} \tn % Row Count 3 (+ 1) % Row 2 \SetRowColor{LightBackground} \mymulticolumn{1}{x{5.377cm}}{`let fullName = firstName + " " + lastName;`} \tn % Row Count 4 (+ 1) % Row 3 \SetRowColor{white} \mymulticolumn{1}{x{5.377cm}}{`alert(fullName);`} \tn % Row Count 5 (+ 1) \hhline{>{\arrayrulecolor{DarkBackground}}-} \SetRowColor{LightBackground} \mymulticolumn{1}{x{5.377cm}}{\{\{link="https://developer.mozilla.org/en-US/docs/Web/API/Window/prompt"\}\}More info\{\{/link\}\}} \tn \hhline{>{\arrayrulecolor{DarkBackground}}-} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{5.377cm}{X} \SetRowColor{DarkBackground} \mymulticolumn{1}{x{5.377cm}}{\bf\textcolor{white}{If else statement}} \tn % Row 0 \SetRowColor{LightBackground} \mymulticolumn{1}{x{5.377cm}}{`let age = prompt("How old are you?");\{\{nl\}\}\{\{nl\}\}if (age \textless{} 18) \{\{\{nl\}\} alert("You cannot apply"); \{\{nl\}\}\} else \{\{\{nl\}\} alert("You can apply"); \{\{nl\}\}\}`} \tn % Row Count 4 (+ 4) \hhline{>{\arrayrulecolor{DarkBackground}}-} \SetRowColor{LightBackground} \mymulticolumn{1}{x{5.377cm}}{\{\{link="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/if...else"\}\}More info\{\{/link\}\}} \tn \hhline{>{\arrayrulecolor{DarkBackground}}-} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{5.377cm}{X} \SetRowColor{DarkBackground} \mymulticolumn{1}{x{5.377cm}}{\bf\textcolor{white}{Logical or}} \tn % Row 0 \SetRowColor{LightBackground} \mymulticolumn{1}{x{5.377cm}}{`if (age \textless{} 18 || gender === "male") \{\{\{nl\}\} alert("You can't do that"); \{\{nl\}\}\}`} \tn % Row Count 2 (+ 2) \hhline{>{\arrayrulecolor{DarkBackground}}-} \SetRowColor{LightBackground} \mymulticolumn{1}{x{5.377cm}}{The code will be executed if one statement is true. \newline \{\{link="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Logical\_OR"\}\}More info\{\{/link\}\}} \tn \hhline{>{\arrayrulecolor{DarkBackground}}-} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{5.377cm}{X} \SetRowColor{DarkBackground} \mymulticolumn{1}{x{5.377cm}}{\bf\textcolor{white}{Logical and}} \tn % Row 0 \SetRowColor{LightBackground} \mymulticolumn{1}{x{5.377cm}}{`if (continent === "Europe" \&\& language === "Portuguese") \{\{\{nl\}\} alert("You are from Portugal 🇵🇹"); \{\{nl\}\}\} else \{\{\{nl\}\} alert("You are not from Portugal"); \{\{nl\}\}\}`} \tn % Row Count 4 (+ 4) \hhline{>{\arrayrulecolor{DarkBackground}}-} \SetRowColor{LightBackground} \mymulticolumn{1}{x{5.377cm}}{The code will be executed if both statements are true. \newline \{\{link="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Logical\_AND"\}\}More info\{\{/link\}\}} \tn \hhline{>{\arrayrulecolor{DarkBackground}}-} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{5.377cm}{X} \SetRowColor{DarkBackground} \mymulticolumn{1}{x{5.377cm}}{\bf\textcolor{white}{Comparison and logical operators}} \tn % Row 0 \SetRowColor{LightBackground} \mymulticolumn{1}{x{5.377cm}}{`2 \textgreater{} 3 // false \{\{nl\}\}2 \textless{} 3 // true \{\{nl\}\}2 \textless{}= 2 // true \{\{nl\}\}3 \textgreater{}= 2 // true \{\{nl\}\}2 === 5 // false \{\{nl\}\}2 !== 3 // true \{\{nl\}\}1 + 2 === 4 // false`} \tn % Row Count 4 (+ 4) \hhline{>{\arrayrulecolor{DarkBackground}}-} \SetRowColor{LightBackground} \mymulticolumn{1}{x{5.377cm}}{\{\{link="https://www.programiz.com/javascript/comparison-logical"\}\}More info\{\{/link\}\}} \tn \hhline{>{\arrayrulecolor{DarkBackground}}-} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{5.377cm}{X} \SetRowColor{DarkBackground} \mymulticolumn{1}{x{5.377cm}}{\bf\textcolor{white}{Get Date-Time info}} \tn % Row 0 \SetRowColor{LightBackground} \mymulticolumn{1}{x{5.377cm}}{`let now = new Date();\{\{nl\}\}now.getMinutes(); // 0,1,2, 12\{\{nl\}\}now.getHours(); //1, 2, 3, 4\{\{nl\}\}now.getDate(); //1, 2, 3, 4\{\{nl\}\}now.getDay(); // 0, 1, 2\{\{nl\}\}now.getMonth(); // 0, 1, 2\{\{nl\}\}now.getFullYear(); // 2021`} \tn % Row Count 5 (+ 5) \hhline{>{\arrayrulecolor{DarkBackground}}-} \SetRowColor{LightBackground} \mymulticolumn{1}{x{5.377cm}}{\{\{link="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global\_Objects/Date"\}\}More info\{\{/link\}\}} \tn \hhline{>{\arrayrulecolor{DarkBackground}}-} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{5.377cm}{X} \SetRowColor{DarkBackground} \mymulticolumn{1}{x{5.377cm}}{\bf\textcolor{white}{Array}} \tn % Row 0 \SetRowColor{LightBackground} \mymulticolumn{1}{x{5.377cm}}{{\bf{Initialization}} \{\{nl\}\} `let numbers = {[}5, 10, 15, 20{]};`} \tn % Row Count 2 (+ 2) % Row 1 \SetRowColor{white} \mymulticolumn{1}{x{5.377cm}}{{\bf{Add}} \{\{nl\}\} `numbers.push(25);`} \tn % Row Count 3 (+ 1) % Row 2 \SetRowColor{LightBackground} \mymulticolumn{1}{x{5.377cm}}{{\bf{Set}} \{\{nl\}\} `numbers{[}2{]} = 30;`} \tn % Row Count 4 (+ 1) % Row 3 \SetRowColor{white} \mymulticolumn{1}{x{5.377cm}}{{\bf{Delete}} \{\{nl\}\} `delete numbers{[}1{]};`} \tn % Row Count 5 (+ 1) % Row 4 \SetRowColor{LightBackground} \mymulticolumn{1}{x{5.377cm}}{{\bf{Unshift}} \{\{nl\}\} `numbers.unshift(1);`} \tn % Row Count 6 (+ 1) % Row 5 \SetRowColor{white} \mymulticolumn{1}{x{5.377cm}}{{\bf{Check Existance}} \{\{nl\}\} `numbers.include(25);`} \tn % Row Count 7 (+ 1) % Row 6 \SetRowColor{LightBackground} \mymulticolumn{1}{x{5.377cm}}{{\bf{Pop}} \{\{nl\}\} `let lastNumber = numbers.pop(); // Remove the last item`} \tn % Row Count 9 (+ 2) % Row 7 \SetRowColor{white} \mymulticolumn{1}{x{5.377cm}}{{\bf{Shift}} \{\{nl\}\} `let removedNumber = numbers.shift(); // Remove the first item`} \tn % Row Count 11 (+ 2) % Row 8 \SetRowColor{LightBackground} \mymulticolumn{1}{x{5.377cm}}{{\bf{Get Index}} \{\{nl\}\} `let index = numbers.indexOf(15);`} \tn % Row Count 13 (+ 2) % Row 9 \SetRowColor{white} \mymulticolumn{1}{x{5.377cm}}{{\bf{Loop}} \{\{nl\}\} `for (let num of numbers) \{ \{\{nl\}\} console.log(num); \{\{nl\}\}\}`} \tn % Row Count 15 (+ 2) % Row 10 \SetRowColor{LightBackground} \mymulticolumn{1}{x{5.377cm}}{{\bf{Clear}} \{\{nl\}\} `numbers = {[}{]};`} \tn % Row Count 16 (+ 1) \hhline{>{\arrayrulecolor{DarkBackground}}-} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{5.377cm}{X} \SetRowColor{DarkBackground} \mymulticolumn{1}{x{5.377cm}}{\bf\textcolor{white}{List}} \tn % Row 0 \SetRowColor{LightBackground} \mymulticolumn{1}{x{5.377cm}}{{\bf{Declaration}} \{\{nl\}\} `let temperatures = new List():`} \tn % Row Count 2 (+ 2) % Row 1 \SetRowColor{white} \mymulticolumn{1}{x{5.377cm}}{{\bf{Add}} \{\{nl\}\}`temperatures.add(22);\{\{nl\}\}temperatures.add(25);\{\{nl\}\}temperatures.add(27);\{\{nl\}\}temperatures.add(20);`} \tn % Row Count 5 (+ 3) % Row 2 \SetRowColor{LightBackground} \mymulticolumn{1}{x{5.377cm}}{{\bf{Set}} \{\{nl\}\} `temperatures.set(2, 26);`} \tn % Row Count 6 (+ 1) % Row 3 \SetRowColor{white} \mymulticolumn{1}{x{5.377cm}}{{\bf{Get Item At Index}} \{\{nl\}\} `let temp = temperatures.get(1);`} \tn % Row Count 8 (+ 2) % Row 4 \SetRowColor{LightBackground} \mymulticolumn{1}{x{5.377cm}}{{\bf{Check Existance}} \{\{nl\}\} \seqsplit{`temperatures.contains(27);`}} \tn % Row Count 10 (+ 2) % Row 5 \SetRowColor{white} \mymulticolumn{1}{x{5.377cm}}{{\bf{Remove}} \{\{nl\}\} \seqsplit{`temperatures.remove(20);`}} \tn % Row Count 11 (+ 1) % Row 6 \SetRowColor{LightBackground} \mymulticolumn{1}{x{5.377cm}}{{\bf{Size}} \{\{nl\}\} `temeratures.size();`} \tn % Row Count 12 (+ 1) % Row 7 \SetRowColor{white} \mymulticolumn{1}{x{5.377cm}}{{\bf{Loop}} \{\{nl\}\} `for (let temp of temperatures.toArray()) \{\{\{nl\}\} console.log(temp); \{\{nl\}\}\}`} \tn % Row Count 14 (+ 2) % Row 8 \SetRowColor{LightBackground} \mymulticolumn{1}{x{5.377cm}}{{\bf{Clear}} \{\{nl\}\} `temperatures.clear();`} \tn % Row Count 15 (+ 1) \hhline{>{\arrayrulecolor{DarkBackground}}-} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{5.377cm}{X} \SetRowColor{DarkBackground} \mymulticolumn{1}{x{5.377cm}}{\bf\textcolor{white}{HashSet}} \tn % Row 0 \SetRowColor{LightBackground} \mymulticolumn{1}{x{5.377cm}}{{\bf{Declaration}} \{\{nl\}\} `let travelDestinations = new HashSet();`} \tn % Row Count 2 (+ 2) % Row 1 \SetRowColor{white} \mymulticolumn{1}{x{5.377cm}}{{\bf{Add}} \{\{nl\}\} `travelDestinations.add("Paris");\{\{nl\}\}travelDestinations.add("Tokyo");\{\{nl\}\}travelDestinations.add("New York");\{\{nl\}\}travelDestinations.add("Sydney");`} \tn % Row Count 6 (+ 4) % Row 2 \SetRowColor{LightBackground} \mymulticolumn{1}{x{5.377cm}}{{\bf{Values}} \{\{nl\}\} \seqsplit{`travelDestinations.values();`}} \tn % Row Count 7 (+ 1) % Row 3 \SetRowColor{white} \mymulticolumn{1}{x{5.377cm}}{{\bf{Delete}} \{\{nl\}\} \seqsplit{`travelDestinations.delete("Sydney");`}} \tn % Row Count 9 (+ 2) % Row 4 \SetRowColor{LightBackground} \mymulticolumn{1}{x{5.377cm}}{{\bf{Size}} \{\{nl\}\} \seqsplit{`travelDestination.size();`}} \tn % Row Count 10 (+ 1) % Row 5 \SetRowColor{white} \mymulticolumn{1}{x{5.377cm}}{{\bf{Loop}} \{\{nl\}\} `for (let city of \seqsplit{travelDestinations.values())} \{\{\{nl\}\} console.log(\textbackslash{}`Travel to: \$\{city\}\textbackslash{}`); \{\{nl\}\}\}`} \tn % Row Count 13 (+ 3) % Row 6 \SetRowColor{LightBackground} \mymulticolumn{1}{x{5.377cm}}{{\bf{Clear}} \{\{nl\}\} \seqsplit{`travelDestination.clear();`}} \tn % Row Count 14 (+ 1) \hhline{>{\arrayrulecolor{DarkBackground}}-} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{5.377cm}{X} \SetRowColor{DarkBackground} \mymulticolumn{1}{x{5.377cm}}{\bf\textcolor{white}{Queue}} \tn % Row 0 \SetRowColor{LightBackground} \mymulticolumn{1}{x{5.377cm}}{{\bf{Declaration}} \{\{nl\}\} `let bankQueue = new Queue();`} \tn % Row Count 2 (+ 2) % Row 1 \SetRowColor{white} \mymulticolumn{1}{x{5.377cm}}{{\bf{Enqueue}} \{\{nl\}\} `bankQueue.enqueue("John");\{\{nl\}\}bankQueue.enqueue("Emma");\{\{nl\}\}bankQueue.enqueue("Lucas");\{\{nl\}\}bankQueue.enqueue("Sophia");`} \tn % Row Count 5 (+ 3) % Row 2 \SetRowColor{LightBackground} \mymulticolumn{1}{x{5.377cm}}{{\bf{Dequeue}} \{\{nl\}\} `bankQueue.dequeue();`} \tn % Row Count 6 (+ 1) % Row 3 \SetRowColor{white} \mymulticolumn{1}{x{5.377cm}}{{\bf{Front}} \{\{nl\}\} `bankQueue.front(); // Get the front of the queue`} \tn % Row Count 8 (+ 2) % Row 4 \SetRowColor{LightBackground} \mymulticolumn{1}{x{5.377cm}}{{\bf{Check Existance}} \{\{nl\}\} \seqsplit{`bankQueue.contains("Emma");`}} \tn % Row Count 10 (+ 2) % Row 5 \SetRowColor{white} \mymulticolumn{1}{x{5.377cm}}{{\bf{Size}} \{\{nl\}\} `bankQueue.size();`} \tn % Row Count 11 (+ 1) \hhline{>{\arrayrulecolor{DarkBackground}}-} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{5.377cm}{X} \SetRowColor{DarkBackground} \mymulticolumn{1}{x{5.377cm}}{\bf\textcolor{white}{LinkedList}} \tn % Row 0 \SetRowColor{LightBackground} \mymulticolumn{1}{x{5.377cm}}{{\bf{Declaration}} \{\{nl\}\} `let train = new LinkedList();`} \tn % Row Count 2 (+ 2) % Row 1 \SetRowColor{white} \mymulticolumn{1}{x{5.377cm}}{{\bf{Append}} \{\{nl\}\} `train.append("Engine Car");\{\{nl\}\}train.append("Passenger Car 1");\{\{nl\}\}train.append("Dining Car");\{\{nl\}\}train.append("Passenger Car 2");\{\{nl\}\}train.append("Cargo Car");`} \tn % Row Count 6 (+ 4) % Row 2 \SetRowColor{LightBackground} \mymulticolumn{1}{x{5.377cm}}{{\bf{Head}} \{\{nl\}\} `let car = train.getHead();`} \tn % Row Count 7 (+ 1) % Row 3 \SetRowColor{white} \mymulticolumn{1}{x{5.377cm}}{{\bf{Get At Index}} \{\{nl\}\} `let car = train.getAt(2);`} \tn % Row Count 9 (+ 2) % Row 4 \SetRowColor{LightBackground} \mymulticolumn{1}{x{5.377cm}}{{\bf{Add At Index}} \{\{nl\}\} `train.addAt(3, "Luxury Car");`} \tn % Row Count 11 (+ 2) % Row 5 \SetRowColor{white} \mymulticolumn{1}{x{5.377cm}}{{\bf{Prepend}} \{\{nl\}\} `train.prepend("Pilot Car"); // Add at the front`} \tn % Row Count 13 (+ 2) % Row 6 \SetRowColor{LightBackground} \mymulticolumn{1}{x{5.377cm}}{{\bf{Remove}} \{\{nl\}\} `train.remove("Dining Car");`} \tn % Row Count 14 (+ 1) % Row 7 \SetRowColor{white} \mymulticolumn{1}{x{5.377cm}}{{\bf{Remove At Index}} \{\{nl\}\} `train.removeAt(2);`} \tn % Row Count 15 (+ 1) % Row 8 \SetRowColor{LightBackground} \mymulticolumn{1}{x{5.377cm}}{{\bf{Contains}} \{\{nl\}\} `train.contains("Dining Car");`} \tn % Row Count 17 (+ 2) % Row 9 \SetRowColor{white} \mymulticolumn{1}{x{5.377cm}}{{\bf{Loop}} \{\{nl\}\} `for (let car of train) \{\{\{nl\}\} console.log(\textbackslash{}`Inspecting car: \$\{car\}\textbackslash{}`); \{\{nl\}\}\}`} \tn % Row Count 20 (+ 3) \hhline{>{\arrayrulecolor{DarkBackground}}-} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{5.377cm}{X} \SetRowColor{DarkBackground} \mymulticolumn{1}{x{5.377cm}}{\bf\textcolor{white}{Dictionary}} \tn % Row 0 \SetRowColor{LightBackground} \mymulticolumn{1}{x{5.377cm}}{{\bf{Declaration}} \{\{nl\}\} `let bookAuthors = new Dictionary();`} \tn % Row Count 2 (+ 2) % Row 1 \SetRowColor{white} \mymulticolumn{1}{x{5.377cm}}{{\bf{Add}} \{\{nl\}\} `bookAuthors.add("Harry Potter", "J.K. Rowling");\{\{nl\}\}bookAuthors.add("The Hobbit", "J.R.R. Tolkien");\{\{nl\}\}bookAuthors.add("Dune", "Frank Herbert");`} \tn % Row Count 6 (+ 4) % Row 2 \SetRowColor{LightBackground} \mymulticolumn{1}{x{5.377cm}}{{\bf{Check Existance Key}} \{\{nl\}\} \seqsplit{`bookAuthors.hasKey("Dune");`}} \tn % Row Count 8 (+ 2) % Row 3 \SetRowColor{white} \mymulticolumn{1}{x{5.377cm}}{{\bf{Check Existance Value}} \{\{nl\}\} \seqsplit{`bookAuthors.hasValue("J.K.} Rowling");`} \tn % Row Count 10 (+ 2) % Row 4 \SetRowColor{LightBackground} \mymulticolumn{1}{x{5.377cm}}{{\bf{Remove Pair}} \{\{nl\}\} `bookAuthors.remove("The Hobbit");`} \tn % Row Count 12 (+ 2) % Row 5 \SetRowColor{white} \mymulticolumn{1}{x{5.377cm}}{{\bf{Keys}} \{\{nl\}\} `bookAuthors.keys();`} \tn % Row Count 13 (+ 1) % Row 6 \SetRowColor{LightBackground} \mymulticolumn{1}{x{5.377cm}}{{\bf{Values}} \{\{nl\}\} `bookAuthors.values();`} \tn % Row Count 14 (+ 1) % Row 7 \SetRowColor{white} \mymulticolumn{1}{x{5.377cm}}{{\bf{Entries}} \{\{nl\}\} `bookAuthors.entries();`} \tn % Row Count 15 (+ 1) % Row 8 \SetRowColor{LightBackground} \mymulticolumn{1}{x{5.377cm}}{{\bf{Size}} \{\{nl\}\} `bookAuthors.size();`} \tn % Row Count 16 (+ 1) % Row 9 \SetRowColor{white} \mymulticolumn{1}{x{5.377cm}}{{\bf{Clear}} \{\{nl\}\} `bookAuthors.clear();`} \tn % Row Count 17 (+ 1) \hhline{>{\arrayrulecolor{DarkBackground}}-} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{5.377cm}{X} \SetRowColor{DarkBackground} \mymulticolumn{1}{x{5.377cm}}{\bf\textcolor{white}{SortedList}} \tn % Row 0 \SetRowColor{LightBackground} \mymulticolumn{1}{x{5.377cm}}{{\bf{Initialization with custom comparator}} \{\{nl\}\} `const byPageCount = (a, b) =\textgreater{} a.pages - b.pages;\{\{nl\}\}let bookshelf = new \seqsplit{SortedList(byPageCount);`}} \tn % Row Count 3 (+ 3) % Row 1 \SetRowColor{white} \mymulticolumn{1}{x{5.377cm}}{{\bf{Add}} \{\{nl\}\} `let book1 = \{ title: "Short Stories", pages: 150 \};\{\{nl\}\}let book2 = \{ title: "Novel", pages: 320 \};\{\{nl\}\}let book3 = \{ title: "Poems", pages: 80 \};\{\{nl\}\}let book4 = \{ title: "Long Novel", pages: 480 \};\{\{nl\}\}bookshelf.add(book1);\{\{nl\}\}bookshelf.add(book2);\{\{nl\}\}bookshelf.add(book3);`} \tn % Row Count 9 (+ 6) % Row 2 \SetRowColor{LightBackground} \mymulticolumn{1}{x{5.377cm}}{{\bf{Get At Index}} \{\{nl\}\} `let selectedBook = bookshelf.get(0);`} \tn % Row Count 11 (+ 2) % Row 3 \SetRowColor{white} \mymulticolumn{1}{x{5.377cm}}{{\bf{Contains}} \{\{nl\}\} \seqsplit{`bookshelf.contains(book3);`}} \tn % Row Count 12 (+ 1) % Row 4 \SetRowColor{LightBackground} \mymulticolumn{1}{x{5.377cm}}{{\bf{Remove}} \{\{nl\}\} \seqsplit{`bookshelf.remove(book3);`}} \tn % Row Count 13 (+ 1) % Row 5 \SetRowColor{white} \mymulticolumn{1}{x{5.377cm}}{{\bf{Min}} \{\{nl\}\} `let smallestBook = bookshelf.min();`} \tn % Row Count 15 (+ 2) % Row 6 \SetRowColor{LightBackground} \mymulticolumn{1}{x{5.377cm}}{{\bf{Max}} \{\{nl\}\} `let largestBook = bookshelf.max();`} \tn % Row Count 17 (+ 2) % Row 7 \SetRowColor{white} \mymulticolumn{1}{x{5.377cm}}{{\bf{Size}} \{\{nl\}\} `bookshelf.size();`} \tn % Row Count 18 (+ 1) % Row 8 \SetRowColor{LightBackground} \mymulticolumn{1}{x{5.377cm}}{{\bf{Loop}} \{\{nl\}\} `for (let book of bookshelf.toArray()) \{\{\{nl\}\} console.log(\textbackslash{}`\$\{book.title\} (\$\{book.pages\} pages)\textbackslash{}`); \{\{nl\}\}\}`} \tn % Row Count 21 (+ 3) % Row 9 \SetRowColor{white} \mymulticolumn{1}{x{5.377cm}}{{\bf{Clear}} \{\{nl\}\} `bookshelf.clear();`} \tn % Row Count 22 (+ 1) \hhline{>{\arrayrulecolor{DarkBackground}}-} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{5.377cm}{X} \SetRowColor{DarkBackground} \mymulticolumn{1}{x{5.377cm}}{\bf\textcolor{white}{SortedSet}} \tn % Row 0 \SetRowColor{LightBackground} \mymulticolumn{1}{x{5.377cm}}{{\bf{Initialization with a custom comparator}} \{\{nl\}\} `const byScore = (a, b) =\textgreater{} a - b;\{\{nl\}\}let examScores = new SortedSet(byScore);`} \tn % Row Count 3 (+ 3) % Row 1 \SetRowColor{white} \mymulticolumn{1}{x{5.377cm}}{{\bf{Add}} \{\{nl\}\} `examScores.add(92);\{\{nl\}\}examScores.add(85);\{\{nl\}\}examScores.add(78);\{\{nl\}\}examScores.add(92);`} \tn % Row Count 6 (+ 3) % Row 2 \SetRowColor{LightBackground} \mymulticolumn{1}{x{5.377cm}}{{\bf{Check Existance}} \{\{nl\}\} `examScores.has(85);`} \tn % Row Count 7 (+ 1) % Row 3 \SetRowColor{white} \mymulticolumn{1}{x{5.377cm}}{{\bf{Delete}} \{\{nl\}\} `examScores.delete(78);`} \tn % Row Count 8 (+ 1) % Row 4 \SetRowColor{LightBackground} \mymulticolumn{1}{x{5.377cm}}{{\bf{Min}} \{\{nl\}\} `examScores.min();`} \tn % Row Count 9 (+ 1) % Row 5 \SetRowColor{white} \mymulticolumn{1}{x{5.377cm}}{{\bf{Max}} \{\{nl\}\} `examScores.max();`} \tn % Row Count 10 (+ 1) % Row 6 \SetRowColor{LightBackground} \mymulticolumn{1}{x{5.377cm}}{{\bf{Size}} \{\{nl\}\} `examScores.size();`} \tn % Row Count 11 (+ 1) % Row 7 \SetRowColor{white} \mymulticolumn{1}{x{5.377cm}}{{\bf{Loop}} \{\{nl\}\} `for (let score of examScores.toArray()) \{\{\{nl\}\} console.log(\textbackslash{}`Exam score: \$\{score\}\textbackslash{}`); \{\{nl\}\}\}`} \tn % Row Count 14 (+ 3) % Row 8 \SetRowColor{LightBackground} \mymulticolumn{1}{x{5.377cm}}{{\bf{Clear}} \{\{nl\}\} `examScores.clear();`} \tn % Row Count 15 (+ 1) \hhline{>{\arrayrulecolor{DarkBackground}}-} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{5.377cm}{X} \SetRowColor{DarkBackground} \mymulticolumn{1}{x{5.377cm}}{\bf\textcolor{white}{Stack}} \tn % Row 0 \SetRowColor{LightBackground} \mymulticolumn{1}{x{5.377cm}}{{\bf{Declaration}} \{\{nl\}\} `let browsingHistory = new Stack();`} \tn % Row Count 2 (+ 2) % Row 1 \SetRowColor{white} \mymulticolumn{1}{x{5.377cm}}{{\bf{Push}} \{\{nl\}\} \seqsplit{`browsingHistory.push("https://www.example}.com");\{\{nl\}\}browsingHistory.push("https://www.google.com");\{\{nl\}\}browsingHistory.push("https://www.stackoverflow.com");`} \tn % Row Count 6 (+ 4) % Row 2 \SetRowColor{LightBackground} \mymulticolumn{1}{x{5.377cm}}{{\bf{Peek}} \{\{nl\}\} `let first = browsingHistory.peek();`} \tn % Row Count 8 (+ 2) % Row 3 \SetRowColor{white} \mymulticolumn{1}{x{5.377cm}}{{\bf{Pop}} \{\{nl\}\} `let item = browsingHistory.pop();`} \tn % Row Count 9 (+ 1) % Row 4 \SetRowColor{LightBackground} \mymulticolumn{1}{x{5.377cm}}{{\bf{Size}} \{\{nl\}\} \seqsplit{`browsingHistory.size();`}} \tn % Row Count 10 (+ 1) \hhline{>{\arrayrulecolor{DarkBackground}}-} \end{tabularx} \par\addvspace{1.3em} % That's all folks \end{multicols*} \end{document}