\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{krabat1 (krabat1)} \pdfinfo{ /Title (javascript.pdf) /Creator (Cheatography) /Author (krabat1 (krabat1)) /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}{AABBAA} \definecolor{LightBackground}{HTML}{F4F6F4} \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}{krabat1 (krabat1)} via \textcolor{DarkBackground}{\uline{cheatography.com/2778/cs/31328/}}} \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}krabat1 (krabat1) \\ \uline{cheatography.com/krabat1} \\ \end{tabulary} \vfill \columnbreak \begin{tabulary}{5.8cm}{L} \SetRowColor{FootBackground} \mymulticolumn{1}{p{5.377cm}}{\bf\textcolor{white}{Cheat Sheet}} \\ \vspace{-2pt}Not Yet Published.\\ Updated 5th January, 2024.\\ 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{1.6708 cm} x{0.8354 cm} x{0.8354 cm} x{0.8354 cm} } \SetRowColor{DarkBackground} \mymulticolumn{4}{x{5.377cm}}{\bf\textcolor{white}{Variable types}} \tn % Row 0 \SetRowColor{LightBackground} \{\{fa-table\}\} & var & let & const \tn % Row Count 1 (+ 1) % Row 1 \SetRowColor{white} block scoped* & \{\{fa-remove\}\} & \{\{fa-check\}\} & \{\{fa-check\}\} \tn % Row Count 3 (+ 2) % Row 2 \SetRowColor{LightBackground} tdz** & \{\{fa-remove\}\} & \{\{fa-check\}\} & \{\{fa-check\}\} \tn % Row Count 5 (+ 2) % Row 3 \SetRowColor{white} creates global property{\emph{*}} & \{\{fa-check\}\} & \{\{fa-remove\}\} & \{\{fa-remove\}\} \tn % Row Count 7 (+ 2) % Row 4 \SetRowColor{LightBackground} reassignable{\emph{*}}* & \{\{fa-check\}\} & \{\{fa-check\}\} & \{\{fa-remove\}\} \tn % Row Count 9 (+ 2) % Row 5 \SetRowColor{white} redeclarable{\bf{*}} & \{\{fa-check\}\} & \{\{fa-remove\}\} & \{\{fa-remove\}\} \tn % Row Count 11 (+ 2) \hhline{>{\arrayrulecolor{DarkBackground}}----} \SetRowColor{LightBackground} \mymulticolumn{4}{x{5.377cm}}{\seqsplit{https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Strict\_mode} \newline {\emph{ \seqsplit{https://medium.com/@allansendagi/block-scope-in-javascript-8fd2f909e848} \newline }}{\emph{*}} \seqsplit{https://discuss.codecademy.com/t/what-is-the-difference-between-let-and-var-when-declaring-and-what-about-reassigning/492581/2} \newline \newline \newline https://www.valentinog.com/blog/var/ \newline https://www.freecodecamp.org/news/var-let-and-const-whats-the-difference/ \newline https://fontawesome.com/v3/icons/} \tn \hhline{>{\arrayrulecolor{DarkBackground}}----} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{5.377cm}{x{2.78712 cm} x{2.18988 cm} } \SetRowColor{DarkBackground} \mymulticolumn{2}{x{5.377cm}}{\bf\textcolor{white}{Data types}} \tn % Row 0 \SetRowColor{LightBackground} var age = 18; & // number \tn % Row Count 1 (+ 1) % Row 1 \SetRowColor{white} var name = "Jane"; & // string \tn % Row Count 2 (+ 1) % Row 2 \SetRowColor{LightBackground} var truth = false; & // boolean \tn % Row Count 3 (+ 1) % Row 3 \SetRowColor{white} var sheets = {[}"HTML","CSS","JS"{]}; & // array \tn % Row Count 5 (+ 2) % Row 4 \SetRowColor{LightBackground} var a; typeof a; & // undefined \tn % Row Count 6 (+ 1) % Row 5 \SetRowColor{white} var a = null; & // value null \tn % Row Count 7 (+ 1) % Row 6 \SetRowColor{LightBackground} \mymulticolumn{2}{x{5.377cm}}{{\bf{Objects:}}} \tn % Row Count 8 (+ 1) % Row 7 \SetRowColor{white} \{\{rowspan=5\}\}var student = \{ \{\{nl\}\}firstName:"Jane", \{\{nl\}\}lastName:"Doe", \{\{nl\}\}age:18, \{\{nl\}\}height:170,\{\{nl\}\}fullName : function() \{\{\{nl\}\}return this.firstName + " " + this.lastName;\{\{nl\}\}\}\{\{nl\}\}\}; & // object name \tn % Row Count 18 (+ 10) % Row 8 \SetRowColor{LightBackground} & // list of properties and values \tn % Row Count 20 (+ 2) % Row 9 \SetRowColor{white} & // object function \tn % Row Count 22 (+ 2) % Row 10 \SetRowColor{LightBackground} \mymulticolumn{2}{x{5.377cm}}{} \tn % Row Count 22 (+ 0) % Row 11 \SetRowColor{white} & // object end \tn % Row Count 23 (+ 1) % Row 12 \SetRowColor{LightBackground} student.age = 19; & // setting value \tn % Row Count 24 (+ 1) % Row 13 \SetRowColor{white} student{[}age{]}++; & // incrementing \tn % Row Count 25 (+ 1) % Row 14 \SetRowColor{LightBackground} name = student.fullName(); & // call object function \tn % Row Count 27 (+ 2) % Row 15 \SetRowColor{white} \mymulticolumn{2}{x{5.377cm}}{} \tn % Row Count 27 (+ 0) \hhline{>{\arrayrulecolor{DarkBackground}}--} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{5.377cm}{x{1.60195 cm} x{1.3731 cm} x{1.60195 cm} } \SetRowColor{DarkBackground} \mymulticolumn{3}{x{5.377cm}}{\bf\textcolor{white}{Operators}} \tn % Row 0 \SetRowColor{LightBackground} & {\bf{Comparison Operators}} & \{\{popup="https://www.w3schools.com/jsref/jsref\_operators.asp"\}\}\{\{ar\}\}\{\{fa-link\}\}\{\{/popup\}\} \tn % Row Count 7 (+ 7) % Row 1 \SetRowColor{white} \mymulticolumn{3}{x{5.377cm}}{Comparison operators {\bf{compare}} two values and return a boolean value, either `true` or `false`.} \tn % Row Count 9 (+ 2) % Row 2 \SetRowColor{LightBackground} {\bf{==}} & Equal to & `5==5; //true` \tn % Row Count 10 (+ 1) % Row 3 \SetRowColor{white} {\bf{!=}} & Not equal to & `5!=5; //false` \tn % Row Count 12 (+ 2) % Row 4 \SetRowColor{LightBackground} {\bf{\textgreater{}}} & Greater than & `3\textgreater{}2; //true` \tn % Row Count 13 (+ 1) % Row 5 \SetRowColor{white} {\bf{\textgreater{}=}} & Greater than or equal to & `3\textgreater{}=3; //true` \tn % Row Count 15 (+ 2) % Row 6 \SetRowColor{LightBackground} {\bf{\textless{}}} & Less than & `3\textless{}2; //false` \tn % Row Count 16 (+ 1) % Row 7 \SetRowColor{white} {\bf{\textless{}=}} & Less than or equal to & `2\textless{}=2; //true` \tn % Row Count 18 (+ 2) % Row 8 \SetRowColor{LightBackground} {\bf{===}} & Strict equal to & `5==='5'; //false` \tn % Row Count 20 (+ 2) % Row 9 \SetRowColor{white} {\bf{!==}} & Strict not equal to & `5!=='5'; //true` \tn % Row Count 22 (+ 2) % Row 10 \SetRowColor{LightBackground} & {\bf{Logical Operators}} & \tn % Row Count 24 (+ 2) % Row 11 \SetRowColor{white} \mymulticolumn{3}{x{5.377cm}}{Logical operators perform logical operations and return a boolean value, either `true` or `false`.} \tn % Row Count 26 (+ 2) % Row 12 \SetRowColor{LightBackground} {\bf{\&\&}} & Logical AND & `true \&\& false; // false` \tn % Row Count 28 (+ 2) % Row 13 \SetRowColor{white} {\bf{||}} & Logical OR & `true || false; // true` \tn % Row Count 30 (+ 2) \end{tabularx} \par\addvspace{1.3em} \vfill \columnbreak \begin{tabularx}{5.377cm}{x{1.60195 cm} x{1.3731 cm} x{1.60195 cm} } \SetRowColor{DarkBackground} \mymulticolumn{3}{x{5.377cm}}{\bf\textcolor{white}{Operators (cont)}} \tn % Row 14 \SetRowColor{LightBackground} {\bf{!}} & Logical NOT & `!true; // false` \tn % Row Count 2 (+ 2) % Row 15 \SetRowColor{white} {\bf{? :}} & \{\{colspan=2\}\}Ternary operator\{\{nl\}\} & \tn % Row Count 5 (+ 3) % Row 16 \SetRowColor{LightBackground} \mymulticolumn{3}{x{5.377cm}}{Returns value based on the condition} \tn % Row Count 6 (+ 1) % Row 17 \SetRowColor{white} \mymulticolumn{3}{x{5.377cm}}{`(5 \textgreater{} 3) ? 'success' : 'error'; // "success"`} \tn % Row Count 7 (+ 1) % Row 18 \SetRowColor{LightBackground} \mymulticolumn{3}{x{5.377cm}}{`condition ? expressionIfTrue : expressionIfFalse`} \tn % Row Count 8 (+ 1) % Row 19 \SetRowColor{white} & {\bf{Assignment operators}} & \tn % Row Count 10 (+ 2) % Row 20 \SetRowColor{LightBackground} \mymulticolumn{3}{x{5.377cm}}{Assignment operators are used to assign values to variables.} \tn % Row Count 12 (+ 2) % Row 21 \SetRowColor{white} {\bf{=}} & Assignment operator & `a = 7; // 7` \tn % Row Count 14 (+ 2) % Row 22 \SetRowColor{LightBackground} {\bf{+=}} & Addition assignment & `a += 5; // a = a + 5` \tn % Row Count 16 (+ 2) % Row 23 \SetRowColor{white} {\bf{*=}} & \seqsplit{Multiplication} Assignment & `a {\emph{= 3; // a = a }} 3` \tn % Row Count 19 (+ 3) % Row 24 \SetRowColor{LightBackground} {\bf{-=}} & Subtraction Assignment & `a -= 2; // a = a - 2` \tn % Row Count 21 (+ 2) % Row 25 \SetRowColor{white} {\bf{/=}} & Division Assignment & `a /= 2; // a = a / 2` \tn % Row Count 23 (+ 2) % Row 26 \SetRowColor{LightBackground} {\bf{\%=}} & Remainder Assignment & `a \%= 2; // a = a \% 2` \tn % Row Count 25 (+ 2) % Row 27 \SetRowColor{white} {\bf{**=}} & \seqsplit{Exponentiation} Assignment & `a {\bf{= 2; // a = a}}2` \tn % Row Count 28 (+ 3) % Row 28 \SetRowColor{LightBackground} & {\bf{Arithmetic Operators}} & \tn % Row Count 30 (+ 2) \end{tabularx} \par\addvspace{1.3em} \vfill \columnbreak \begin{tabularx}{5.377cm}{x{1.60195 cm} x{1.3731 cm} x{1.60195 cm} } \SetRowColor{DarkBackground} \mymulticolumn{3}{x{5.377cm}}{\bf\textcolor{white}{Operators (cont)}} \tn % Row 29 \SetRowColor{LightBackground} \mymulticolumn{3}{x{5.377cm}}{Arithmetic operators are used to perform arithmetic calculations.} \tn % Row Count 2 (+ 2) % Row 30 \SetRowColor{white} {\bf{+}} & Addition & `x + y` \tn % Row Count 3 (+ 1) % Row 31 \SetRowColor{LightBackground} {\bf{-}} & Subtraction & `x - y` \tn % Row Count 4 (+ 1) % Row 32 \SetRowColor{white} {\bf{*}} & \seqsplit{Multiplication} & `x * y` \tn % Row Count 6 (+ 2) % Row 33 \SetRowColor{LightBackground} {\bf{/}} & Division & `x / y` \tn % Row Count 7 (+ 1) % Row 34 \SetRowColor{white} {\bf{\%}} & Remainder & `x \% y` \tn % Row Count 8 (+ 1) % Row 35 \SetRowColor{LightBackground} {\bf{++}} & Increment (increments by 1) & `++x or x++` \tn % Row Count 11 (+ 3) % Row 36 \SetRowColor{white} {\bf{-{}-}} & Decrement (decrements by 1) & `-{}-x or x-{}-` \tn % Row Count 14 (+ 3) % Row 37 \SetRowColor{LightBackground} {\bf{ }} ** & \seqsplit{Exponentiation} (Power) & `x ** y` \tn % Row Count 16 (+ 2) % Row 38 \SetRowColor{white} & {\bf{Bitwise Operators}} & \tn % Row Count 18 (+ 2) % Row 39 \SetRowColor{LightBackground} \mymulticolumn{3}{x{5.377cm}}{Bitwise operators perform operations on binary representations of numbers.} \tn % Row Count 20 (+ 2) % Row 40 \SetRowColor{white} {\bf{\&}} & Bitwise AND & \tn % Row Count 21 (+ 1) % Row 41 \SetRowColor{LightBackground} {\bf{|}} & Bitwise OR & \tn % Row Count 22 (+ 1) % Row 42 \SetRowColor{white} {\bf{\textasciicircum{}}} & Bitwise XOR & \tn % Row Count 23 (+ 1) % Row 43 \SetRowColor{LightBackground} {\bf{\textasciitilde{}}} & Bitwise NOT & \tn % Row Count 24 (+ 1) % Row 44 \SetRowColor{white} {\bf{\textless{}\textless{}}} & Left shift & \tn % Row Count 25 (+ 1) % Row 45 \SetRowColor{LightBackground} {\bf{\textgreater{}\textgreater{}}} & \seqsplit{Sign-propagating} right shift & \tn % Row Count 28 (+ 3) % Row 46 \SetRowColor{white} {\bf{\textgreater{}\textgreater{}\textgreater{}}} & Zero-fill right shift & \tn % Row Count 30 (+ 2) \end{tabularx} \par\addvspace{1.3em} \vfill \columnbreak \begin{tabularx}{5.377cm}{x{1.60195 cm} x{1.3731 cm} x{1.60195 cm} } \SetRowColor{DarkBackground} \mymulticolumn{3}{x{5.377cm}}{\bf\textcolor{white}{Operators (cont)}} \tn % Row 47 \SetRowColor{LightBackground} & {\bf{String Operators}} & \tn % Row Count 2 (+ 2) % Row 48 \SetRowColor{white} \mymulticolumn{3}{x{5.377cm}}{In JavaScript, you can also use the `+` operator to concatenate (join) two or more strings.} \tn % Row Count 4 (+ 2) % Row 49 \SetRowColor{LightBackground} {\bf{+}} & \seqsplit{Concatenation} operator & \tn % Row Count 6 (+ 2) % Row 50 \SetRowColor{white} & {\bf{Other Operators}} & \tn % Row Count 8 (+ 2) % Row 51 \SetRowColor{LightBackground} \{\{colspan=2\}\}{\bf{,}}\{\{nl\}\}evaluates each of its operands (from left to right) and returns the value of the last operand. & & `let x = 1;`\{\{nl\}\}`x = (x++, x);`\{\{nl\}\}`console.log(x); // 2` \tn % Row Count 17 (+ 9) % Row 52 \SetRowColor{white} \{\{colspan=2\}\}{\bf{delete}}\{\{nl\}\}deletes an object's property, or an element of an array & & `delete x` \tn % Row Count 24 (+ 7) % Row 53 \SetRowColor{LightBackground} \{\{colspan=2\}\}{\bf{typeof}}\{\{nl\}\}returns a string indicating the data type & & `typeof 3; // "number"` \tn % Row Count 30 (+ 6) \end{tabularx} \par\addvspace{1.3em} \vfill \columnbreak \begin{tabularx}{5.377cm}{x{1.60195 cm} x{1.3731 cm} x{1.60195 cm} } \SetRowColor{DarkBackground} \mymulticolumn{3}{x{5.377cm}}{\bf\textcolor{white}{Operators (cont)}} \tn % Row 54 \SetRowColor{LightBackground} \{\{colspan=2\}\}{\bf{void}}\{\{nl\}\}discards the expression's return value & & `void(x)` \tn % Row Count 5 (+ 5) % Row 55 \SetRowColor{white} \{\{colspan=2\}\}{\bf{in}}\{\{nl\}\}returns true if the specified property is in the object & & `prop in object` \tn % Row Count 11 (+ 6) % Row 56 \SetRowColor{LightBackground} \{\{colspan=2\}\}{\bf{instanceof}}\{\{nl\}\}returns true if the specified object is of of the specified object type & & `object instanceof object\_type` \tn % Row Count 19 (+ 8) \hhline{>{\arrayrulecolor{DarkBackground}}---} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{5.377cm}{x{2.4885 cm} x{2.4885 cm} } \SetRowColor{DarkBackground} \mymulticolumn{2}{x{5.377cm}}{\bf\textcolor{white}{Loopz}} \tn % Row 0 \SetRowColor{LightBackground} \seqsplit{https://www.w3schools.com/js/js\_loop\_for.asp} & \seqsplit{https://www.programiz.com/javascript/for-loop} \tn % Row Count 3 (+ 3) % Row 1 \SetRowColor{white} \seqsplit{https://www.w3schools.com/jsref/jsref\_foreach.asp} & \seqsplit{https://www.programiz.com/javascript/forEach} \tn % Row Count 6 (+ 3) % Row 2 \SetRowColor{LightBackground} \seqsplit{https://www.w3schools.com/js/js\_loop\_forof.asp} & \seqsplit{https://www.programiz.com/javascript/for-of} \tn % Row Count 9 (+ 3) % Row 3 \SetRowColor{white} \seqsplit{https://www.w3schools.com/js/js\_loop\_forin.asp} & \seqsplit{https://www.programiz.com/javascript/for-in} \tn % Row Count 12 (+ 3) % Row 4 \SetRowColor{LightBackground} \seqsplit{https://www.w3schools.com/js/js\_loop\_while.asp} & \seqsplit{https://www.programiz.com/javascript/while-loop} \tn % Row Count 15 (+ 3) % Row 5 \SetRowColor{white} \seqsplit{https://www.w3schools.com/js/js\_break.asp} & \seqsplit{https://www.programiz.com/javascript/break-statement} \tn % Row Count 18 (+ 3) % Row 6 \SetRowColor{LightBackground} & \seqsplit{https://www.programiz.com/javascript/continue-statement} \tn % Row Count 21 (+ 3) % Row 7 \SetRowColor{white} \mymulticolumn{2}{x{5.377cm}}{\seqsplit{https://www.w3schools.com/js/js\_iterables.asp}} \tn % Row Count 22 (+ 1) % Row 8 \SetRowColor{LightBackground} \seqsplit{https://www.w3schools.com/js/js\_switch.asp} & \seqsplit{https://www.programiz.com/javascript/switch-statement} \tn % Row Count 25 (+ 3) \hhline{>{\arrayrulecolor{DarkBackground}}--} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{5.377cm}{p{0.4977 cm} p{0.4977 cm} } \SetRowColor{DarkBackground} \mymulticolumn{2}{x{5.377cm}}{\bf\textcolor{white}{Global Methods}} \tn % Row 0 \SetRowColor{LightBackground} \mymulticolumn{2}{x{5.377cm}}{} \tn % Row Count 0 (+ 0) \hhline{>{\arrayrulecolor{DarkBackground}}--} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{5.377cm}{x{1.89126 cm} x{3.08574 cm} } \SetRowColor{DarkBackground} \mymulticolumn{2}{x{5.377cm}}{\bf\textcolor{white}{Math functions III. - Number Methods}} \tn % Row 0 \SetRowColor{LightBackground} \{\{width=35\}\}`isFinite()` & a value is a finite number? \tn % Row Count 2 (+ 2) % Row 1 \SetRowColor{white} `isInteger()` & a value is an integer? \tn % Row Count 3 (+ 1) % Row 2 \SetRowColor{LightBackground} `isNaN()` & a value is Number.NaN? \tn % Row Count 4 (+ 1) % Row 3 \SetRowColor{white} \seqsplit{`isSafeInteger()`} & a value is a safe integer? \tn % Row Count 6 (+ 2) % Row 4 \SetRowColor{LightBackground} \seqsplit{`toExponential(x)`} & Converts a num. into an exponential notation \tn % Row Count 8 (+ 2) % Row 5 \SetRowColor{white} `toFixed(x)` & Formats a num. with x numb.s of digits after the decimal point \tn % Row Count 11 (+ 3) % Row 6 \SetRowColor{LightBackground} \seqsplit{`toLocaleString()`} & Converts a num. into a string, based on the locale settings \tn % Row Count 14 (+ 3) % Row 7 \SetRowColor{white} \seqsplit{`toPrecision(x)`} & Formats a num. to x length \tn % Row Count 16 (+ 2) % Row 8 \SetRowColor{LightBackground} `toString()` & Converts a num. to a string \tn % Row Count 18 (+ 2) % Row 9 \SetRowColor{white} `valueOf()` & Returns the primitive value of a num. \tn % Row Count 20 (+ 2) \hhline{>{\arrayrulecolor{DarkBackground}}--} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{5.377cm}{x{2.63781 cm} x{2.33919 cm} } \SetRowColor{DarkBackground} \mymulticolumn{2}{x{5.377cm}}{\bf\textcolor{white}{Math functions I.}} \tn % Row 0 \SetRowColor{LightBackground} \{\{width=60\}\}Math.round(x.y); \{\{nl\}\}`// x.5\{\{fa-angle-up\}\} x.4\{\{fa-angle-down\}\}` & Math.trunc(x.y) \{\{nl\}\}`// x` \tn % Row Count 4 (+ 4) % Row 1 \SetRowColor{white} Math.ceil(); Math.floor(); \{\{nl\}\}`// \{\{fa-angle-up\}\}\{\{fa-angle-down\}\}` & Math.pow(x,y) \{\{nl\}\}`// x\textasciicircum{}y\textasciicircum{}` \tn % Row Count 8 (+ 4) % Row 2 \SetRowColor{LightBackground} Math.sign() \{\{nl\}\}`// -x, 0, x \{\{fa-long-arrow-right\}\} -1, 0, 1` & Math.abs(-x); \{\{nl\}\}`// x` \tn % Row Count 12 (+ 4) % Row 3 \SetRowColor{white} Math.sqrt(x); Math.cbrt(y); \{\{nl\}\}`// √x ∛y` & Math.exp(x) \{\{nl\}\}`// value of Ex` \tn % Row Count 15 (+ 3) % Row 4 \SetRowColor{LightBackground} Math.min(a,b,c,d); and Math.max(a,b,c,d); & Math.random(); \tn % Row Count 17 (+ 2) % Row 5 \SetRowColor{white} \mymulticolumn{2}{x{5.377cm}}{Math.log(); Math.log2(); Math.log10();} \tn % Row Count 18 (+ 1) \hhline{>{\arrayrulecolor{DarkBackground}}--} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{5.377cm}{x{2.4885 cm} x{2.4885 cm} } \SetRowColor{DarkBackground} \mymulticolumn{2}{x{5.377cm}}{\bf\textcolor{white}{Math functions II. - Angle functions}} \tn % Row 0 \SetRowColor{LightBackground} `sin(x)` \{\{nl\}\} `asin(x)` \{\{nl\}\} `asinh(x)` \{\{nl\}\} `sinh(x)` & // sine of x (x is in rad.)\{\{nl\}\}// arcsine of x, in rad.\{\{nl\}\}// hyperb. arcsine of x\{\{nl\}\}// hyperb. sine of x \tn % Row Count 6 (+ 6) % Row 1 \SetRowColor{white} `cos(x)` \{\{nl\}\} `acos(x)` \{\{nl\}\} `acosh(x)` \{\{nl\}\} `cosh(x)` & // cosine of x (x is in rad.)\{\{nl\}\}// arccosine of x, in rad.\{\{nl\}\}// hyperb. arccosine of x\{\{nl\}\}// hyperb. cosine of x \tn % Row Count 12 (+ 6) % Row 2 \SetRowColor{LightBackground} `tan(x)` \{\{nl\}\} `atan(x)` \{\{nl\}\} \{\{nl\}\} `atan2(y,x)` \{\{nl\}\}\{\{nl\}\} `atanh(x)` \{\{nl\}\} `tanh(x)` & // tang. of an angl\{\{nl\}\}// arctang. of x as a numeric value btw. -PI/2 and PI/2 rad.\{\{nl\}\}// arctang. of the quotient of its arguments\{\{nl\}\}// hyperb. arctang. of x\{\{nl\}\}// hyperb. tang. of a num. \tn % Row Count 22 (+ 10) \hhline{>{\arrayrulecolor{DarkBackground}}--} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{5.377cm}{x{2.33919 cm} x{2.63781 cm} } \SetRowColor{DarkBackground} \mymulticolumn{2}{x{5.377cm}}{\bf\textcolor{white}{String functions}} \tn % Row 0 \SetRowColor{LightBackground} {\bf{length}} & `str.length` \tn % Row Count 1 (+ 1) % Row 1 \SetRowColor{white} \mymulticolumn{2}{x{5.377cm}}{Returns the number of characters in a string} \tn % Row Count 2 (+ 1) % Row 2 \SetRowColor{LightBackground} {\bf{substring()}} & \seqsplit{`str.substring(indexStart}, indexEnd)` \tn % Row Count 4 (+ 2) % Row 3 \SetRowColor{white} \mymulticolumn{2}{x{5.377cm}}{Returns a specified part of the string} \tn % Row Count 5 (+ 1) % Row 4 \SetRowColor{LightBackground} {\bf{slice()}} & \seqsplit{`str.slice(beginIndex}, endIndex)` \tn % Row Count 7 (+ 2) % Row 5 \SetRowColor{white} \mymulticolumn{2}{x{5.377cm}}{Extracts and returns a section of the string} \tn % Row Count 8 (+ 1) % Row 6 \SetRowColor{LightBackground} {\bf{substr()}} & \seqsplit{`str.substr(beginIndex}, length)` \tn % Row Count 10 (+ 2) % Row 7 \SetRowColor{white} \mymulticolumn{2}{x{5.377cm}}{similar to `slice()`, but the second parameter specifies the length of the extracted part.} \tn % Row Count 12 (+ 2) % Row 8 \SetRowColor{LightBackground} {\bf{replace()}} & `str.replace(pattern, replacement)` \tn % Row Count 14 (+ 2) % Row 9 \SetRowColor{white} \mymulticolumn{2}{x{5.377cm}}{replace a substring/pattern in the string} \tn % Row Count 15 (+ 1) % Row 10 \SetRowColor{LightBackground} {\bf{replaceAll()}} & \seqsplit{`str.replaceAll(pattern}, replacement)` \tn % Row Count 17 (+ 2) % Row 11 \SetRowColor{white} \mymulticolumn{2}{x{5.377cm}}{Returns string by replacing all matching patterns} \tn % Row Count 18 (+ 1) % Row 12 \SetRowColor{LightBackground} {\bf{toUpperCase()\{\{nl\}\}toLowerCase()}} & `str.toUpperCase()\{\{nl\}\}str.toLowerCase()` \tn % Row Count 21 (+ 3) % Row 13 \SetRowColor{white} \mymulticolumn{2}{x{5.377cm}}{Returns uppercase/lowercase representation of a string} \tn % Row Count 23 (+ 2) % Row 14 \SetRowColor{LightBackground} {\bf{concat()}} & `str.concat(str1, ..., strN)` \tn % Row Count 25 (+ 2) % Row 15 \SetRowColor{white} \mymulticolumn{2}{x{5.377cm}}{Concatenates the arguments to the calling string} \tn % Row Count 26 (+ 1) % Row 16 \SetRowColor{LightBackground} \textasciitilde{}{\bf{repeat()}} & `str.repeat(count)` \tn % Row Count 27 (+ 1) % Row 17 \SetRowColor{white} \mymulticolumn{2}{x{5.377cm}}{Returns a string by repeating it given times} \tn % Row Count 28 (+ 1) % Row 18 \SetRowColor{LightBackground} {\bf{trim()}} & `str.trim()` \tn % Row Count 29 (+ 1) % Row 19 \SetRowColor{white} \mymulticolumn{2}{x{5.377cm}}{Removes whitespace from both ends of a string} \tn % Row Count 30 (+ 1) \end{tabularx} \par\addvspace{1.3em} \vfill \columnbreak \begin{tabularx}{5.377cm}{x{2.33919 cm} x{2.63781 cm} } \SetRowColor{DarkBackground} \mymulticolumn{2}{x{5.377cm}}{\bf\textcolor{white}{String functions (cont)}} \tn % Row 20 \SetRowColor{LightBackground} {\bf{padStart()\{\{nl\}\}padEnd()}} & \seqsplit{`str.padStart(targetLength}, padString)\{\{nl\}\}str.padEnd(targetLength, padString)` \tn % Row Count 4 (+ 4) % Row 21 \SetRowColor{white} \mymulticolumn{2}{x{5.377cm}}{Pads a string at the start/end to a given length} \tn % Row Count 5 (+ 1) % Row 22 \SetRowColor{LightBackground} {\bf{charAt()}} & `str.charAt(index)` \tn % Row Count 6 (+ 1) % Row 23 \SetRowColor{white} \mymulticolumn{2}{x{5.377cm}}{Returns character at a specified index in string} \tn % Row Count 7 (+ 1) % Row 24 \SetRowColor{LightBackground} {\bf{charCodeAt()}} & \seqsplit{`str.charCodeAt(index)`} \tn % Row Count 9 (+ 2) % Row 25 \SetRowColor{white} \mymulticolumn{2}{x{5.377cm}}{Returns Unicode of the character at given index} \tn % Row Count 10 (+ 1) % Row 26 \SetRowColor{LightBackground} \textasciitilde{}{\bf{fromCharCode()}} & \seqsplit{`String.fromCharCode(num1}, ..., numN)` \tn % Row Count 12 (+ 2) % Row 27 \SetRowColor{white} \mymulticolumn{2}{x{5.377cm}}{Returns a string from the given UTF-16 code units} \tn % Row Count 13 (+ 1) % Row 28 \SetRowColor{LightBackground} \textasciitilde{}{\bf{codePointAt()}} & \seqsplit{`str.codePointAt(pos)`} \tn % Row Count 15 (+ 2) % Row 29 \SetRowColor{white} \mymulticolumn{2}{x{5.377cm}}{Returns the Unicode point value at given index} \tn % Row Count 16 (+ 1) % Row 30 \SetRowColor{LightBackground} \textasciitilde{}{\bf{fromCodePoint()}} & \seqsplit{`String.fromCodePoint(num1}, ..., numN)` \tn % Row Count 18 (+ 2) % Row 31 \SetRowColor{white} \mymulticolumn{2}{x{5.377cm}}{Returns a string using the given code points} \tn % Row Count 19 (+ 1) % Row 32 \SetRowColor{LightBackground} {\bf{split()}} & `str.split(separator, limit)` \tn % Row Count 21 (+ 2) % Row 33 \SetRowColor{white} \mymulticolumn{2}{x{5.377cm}}{Returns the string divided into list of substring} \tn % Row Count 22 (+ 1) % Row 34 \SetRowColor{LightBackground} \mymulticolumn{2}{x{5.377cm}}{{\bf{- - Search Methods - -}}} \tn % Row Count 23 (+ 1) % Row 35 \SetRowColor{white} {\bf{indexOf()\{\{nl\}\}lastIndexOf()}} & \seqsplit{`str.indexOf(searchValue}, fromIndex)\{\{nl\}\}str.lastIndexOf(searchValue, fromIndex)` \tn % Row Count 27 (+ 4) % Row 36 \SetRowColor{LightBackground} \mymulticolumn{2}{x{5.377cm}}{Returns the first index/last index of occurrence of a value} \tn % Row Count 29 (+ 2) % Row 37 \SetRowColor{white} {\bf{search()}} & `str.search(regexp)` \tn % Row Count 30 (+ 1) \end{tabularx} \par\addvspace{1.3em} \vfill \columnbreak \begin{tabularx}{5.377cm}{x{2.33919 cm} x{2.63781 cm} } \SetRowColor{DarkBackground} \mymulticolumn{2}{x{5.377cm}}{\bf\textcolor{white}{String functions (cont)}} \tn % Row 38 \SetRowColor{LightBackground} \mymulticolumn{2}{x{5.377cm}}{Searches for specified value in the string} \tn % Row Count 1 (+ 1) % Row 39 \SetRowColor{white} {\bf{match()}} & `str.match(regexp)` \tn % Row Count 2 (+ 1) % Row 40 \SetRowColor{LightBackground} \mymulticolumn{2}{x{5.377cm}}{Returns result of matching string with a regex} \tn % Row Count 3 (+ 1) % Row 41 \SetRowColor{white} {\bf{matchAll()}} & \seqsplit{`str.matchAll(regexp)`} \tn % Row Count 5 (+ 2) % Row 42 \SetRowColor{LightBackground} \mymulticolumn{2}{x{5.377cm}}{Returns iterator of results matching with a regex} \tn % Row Count 6 (+ 1) % Row 43 \SetRowColor{white} {\bf{includes()}} & \seqsplit{`str.includes(searchString}, position)` \tn % Row Count 8 (+ 2) % Row 44 \SetRowColor{LightBackground} \mymulticolumn{2}{x{5.377cm}}{Checks if given string is found inside a string} \tn % Row Count 9 (+ 1) % Row 45 \SetRowColor{white} {\bf{startsWith()\{\{nl\}\}endsWith()}} & \seqsplit{`str.startsWith(searchString}, position)\{\{nl\}\}str.endsWith(searchString, length)` \tn % Row Count 13 (+ 4) % Row 46 \SetRowColor{LightBackground} \mymulticolumn{2}{x{5.377cm}}{Checks if a string begins/ends with a specified string} \tn % Row Count 15 (+ 2) % Row 47 \SetRowColor{white} {\bf{localeCompare()}} & \seqsplit{`str.localeCompare(compareStr}, locales, options)` \tn % Row Count 18 (+ 3) % Row 48 \SetRowColor{LightBackground} \mymulticolumn{2}{x{5.377cm}}{Compares two strings in the current locale} \tn % Row Count 19 (+ 1) % Row 49 \SetRowColor{white} \mymulticolumn{2}{x{5.377cm}}{{\bf{- - Template Literals - -}} `\$\{...\}`} \tn % Row Count 20 (+ 1) % Row 50 \SetRowColor{LightBackground} \mymulticolumn{2}{x{5.377cm}}{Template literals provide an easy way to interpolate variables and expressions into strings.} \tn % Row Count 22 (+ 2) \hhline{>{\arrayrulecolor{DarkBackground}}--} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{5.377cm}{p{0.4977 cm} x{4.4793 cm} } \SetRowColor{DarkBackground} \mymulticolumn{2}{x{5.377cm}}{\bf\textcolor{white}{Booleans}} \tn % Row 0 \SetRowColor{LightBackground} & `Boolean(expression)` \tn % Row Count 1 (+ 1) % Row 1 \SetRowColor{white} \mymulticolumn{2}{x{5.377cm}}{The `Boolean()` function is used to convert various data types to boolean values.\{\{nl\}\}You can use the `Boolean()` function to find out if an expression is `true`.\{\{nl\}\}See {\bf{Comparison and Logical Operators}}.} \tn % Row Count 6 (+ 5) \hhline{>{\arrayrulecolor{DarkBackground}}--} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{5.377cm}{x{2.58804 cm} x{2.38896 cm} } \SetRowColor{DarkBackground} \mymulticolumn{2}{x{5.377cm}}{\bf\textcolor{white}{Array Functions}} \tn % Row 0 \SetRowColor{LightBackground} `// const array\_name = {[}item1, item2, ...{]}; ` & `// var firstelement = array{[}0{]}` \tn % Row Count 3 (+ 3) % Row 1 \SetRowColor{white} \mymulticolumn{2}{x{5.377cm}}{{\bf{push()}} and {\bf{unshift()}}} \tn % Row Count 4 (+ 1) % Row 2 \SetRowColor{LightBackground} \mymulticolumn{2}{x{5.377cm}}{adds an element at the end/beginning of the array.} \tn % Row Count 5 (+ 1) % Row 3 \SetRowColor{white} \mymulticolumn{2}{x{5.377cm}}{{\bf{pop()}} and {\bf{shift()}}} \tn % Row Count 6 (+ 1) % Row 4 \SetRowColor{LightBackground} \mymulticolumn{2}{x{5.377cm}}{remove the last/first element from an array.} \tn % Row Count 7 (+ 1) % Row 5 \SetRowColor{white} {\bf{length}} & `// var last = array{[}array.length-1{]}` \tn % Row Count 9 (+ 2) % Row 6 \SetRowColor{LightBackground} \mymulticolumn{2}{x{5.377cm}}{returns the number of elements in an array} \tn % Row Count 10 (+ 1) % Row 7 \SetRowColor{white} Arrays is objects... & `typeof(array) // object` \tn % Row Count 12 (+ 2) % Row 8 \SetRowColor{LightBackground} ...but arrays too. & \seqsplit{`Array.isArray(array)} // true` \tn % Row Count 14 (+ 2) \hhline{>{\arrayrulecolor{DarkBackground}}--} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{5.377cm}{p{0.4977 cm} p{0.4977 cm} } \SetRowColor{DarkBackground} \mymulticolumn{2}{x{5.377cm}}{\bf\textcolor{white}{Objects}} \tn % Row 0 \SetRowColor{LightBackground} \mymulticolumn{2}{x{5.377cm}}{} \tn % Row Count 0 (+ 0) \hhline{>{\arrayrulecolor{DarkBackground}}--} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{5.377cm}{p{0.4977 cm} p{0.4977 cm} } \SetRowColor{DarkBackground} \mymulticolumn{2}{x{5.377cm}}{\bf\textcolor{white}{Events}} \tn % Row 0 \SetRowColor{LightBackground} \mymulticolumn{2}{x{5.377cm}}{} \tn % Row Count 0 (+ 0) \hhline{>{\arrayrulecolor{DarkBackground}}--} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{5.377cm}{p{0.4977 cm} p{0.4977 cm} } \SetRowColor{DarkBackground} \mymulticolumn{2}{x{5.377cm}}{\bf\textcolor{white}{Event listener}} \tn % Row 0 \SetRowColor{LightBackground} \mymulticolumn{2}{x{5.377cm}}{} \tn % Row Count 0 (+ 0) \hhline{>{\arrayrulecolor{DarkBackground}}--} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{5.377cm}{X} \SetRowColor{DarkBackground} \mymulticolumn{1}{x{5.377cm}}{\bf\textcolor{white}{Useful links}} \tn % Row 0 \SetRowColor{LightBackground} \mymulticolumn{1}{x{5.377cm}}{\seqsplit{https://www.w3schools.com/jsref/default.asp}} \tn % Row Count 1 (+ 1) % Row 1 \SetRowColor{white} \mymulticolumn{1}{x{5.377cm}}{\{\{popup="https://developer.mozilla.org/en-US/docs/Web/JavaScript"\}\}mdn web docs \{\{/popup\}\}} \tn % Row Count 3 (+ 2) % Row 2 \SetRowColor{LightBackground} \mymulticolumn{1}{x{5.377cm}}{\{\{popup="https://www.educba.com/software-development/software-development-tutorials/javascript-tutorial/"\}\}educba.com - javascript-tutorial\{\{/popup\}\}} \tn % Row Count 6 (+ 3) % Row 3 \SetRowColor{white} \mymulticolumn{1}{x{5.377cm}}{\seqsplit{https://www.javascripture.com/}} \tn % Row Count 7 (+ 1) % Row 4 \SetRowColor{LightBackground} \mymulticolumn{1}{x{5.377cm}}{\{\{popup="https://www.programiz.com/javascript/get-started"\}\}Programiz - Getting Started\{\{/popup\}\}} \tn % Row Count 9 (+ 2) % Row 5 \SetRowColor{white} \mymulticolumn{1}{x{5.377cm}}{\{\{popup="https://www.codecademy.com/learn/introduction-to-javascript/modules/learn-javascript-introduction/cheatsheet"\}\}Codecademy - Cheatsheets / Learn JavaScript\{\{/popup\}\}} \tn % Row Count 13 (+ 4) % Row 6 \SetRowColor{LightBackground} \mymulticolumn{1}{x{5.377cm}}{\{\{popup="https://htmlcheatsheet.com/js/"\}\}htmlcheatsheet.com/js\{\{/popup\}\}} \tn % Row Count 15 (+ 2) % Row 7 \SetRowColor{white} \mymulticolumn{1}{x{5.377cm}}{\{\{popup="https://websitesetup.org/wp-content/uploads/2020/09/Javascript-Cheat-Sheet.pdf"\}\}Websitesetup - Javascript-Cheat-Sheet.pdf\{\{/popup\}\}} \tn % Row Count 18 (+ 3) % Row 8 \SetRowColor{LightBackground} \mymulticolumn{1}{x{5.377cm}}{\{\{popup="https://javascript.info/"\}\}javascript.info\{\{/popup\}\}} \tn % Row Count 20 (+ 2) \hhline{>{\arrayrulecolor{DarkBackground}}-} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{5.377cm}{p{0.4977 cm} p{0.4977 cm} } \SetRowColor{DarkBackground} \mymulticolumn{2}{x{5.377cm}}{\bf\textcolor{white}{Statements Reference}} \tn % Row 0 \SetRowColor{LightBackground} \mymulticolumn{2}{x{5.377cm}}{} \tn % Row Count 0 (+ 0) \hhline{>{\arrayrulecolor{DarkBackground}}--} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{5.377cm}{p{0.4977 cm} p{0.4977 cm} } \SetRowColor{DarkBackground} \mymulticolumn{2}{x{5.377cm}}{\bf\textcolor{white}{Date Reference}} \tn % Row 0 \SetRowColor{LightBackground} \mymulticolumn{2}{x{5.377cm}}{} \tn % Row Count 0 (+ 0) \hhline{>{\arrayrulecolor{DarkBackground}}--} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{5.377cm}{p{0.4977 cm} p{0.4977 cm} } \SetRowColor{DarkBackground} \mymulticolumn{2}{x{5.377cm}}{\bf\textcolor{white}{Regular expressions}} \tn % Row 0 \SetRowColor{LightBackground} \mymulticolumn{2}{x{5.377cm}}{} \tn % Row Count 0 (+ 0) \hhline{>{\arrayrulecolor{DarkBackground}}--} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{5.377cm}{p{0.4977 cm} p{0.4977 cm} } \SetRowColor{DarkBackground} \mymulticolumn{2}{x{5.377cm}}{\bf\textcolor{white}{Class Reference}} \tn % Row 0 \SetRowColor{LightBackground} \mymulticolumn{2}{x{5.377cm}}{} \tn % Row Count 0 (+ 0) \hhline{>{\arrayrulecolor{DarkBackground}}--} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{5.377cm}{p{0.4977 cm} p{0.4977 cm} } \SetRowColor{DarkBackground} \mymulticolumn{2}{x{5.377cm}}{\bf\textcolor{white}{Error Reference}} \tn % Row 0 \SetRowColor{LightBackground} \mymulticolumn{2}{x{5.377cm}}{} \tn % Row Count 0 (+ 0) \hhline{>{\arrayrulecolor{DarkBackground}}--} \end{tabularx} \par\addvspace{1.3em} % That's all folks \end{multicols*} \end{document}