\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{itsMe} \pdfinfo{ /Title (corejs-interview1.pdf) /Creator (Cheatography) /Author (itsMe) /Subject (CoreJS Interview1 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}{FF3300} \definecolor{LightBackground}{HTML}{FFF2EF} \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{CoreJS Interview1 Cheat Sheet}}}} \\ \normalsize{by \textcolor{DarkBackground}{itsMe} via \textcolor{DarkBackground}{\uline{cheatography.com/189476/cs/39515/}}} \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}itsMe \\ \uline{cheatography.com/itsme} \\ \end{tabulary} \vfill \columnbreak \begin{tabulary}{5.8cm}{L} \SetRowColor{FootBackground} \mymulticolumn{1}{p{5.377cm}}{\bf\textcolor{white}{Cheat Sheet}} \\ \vspace{-2pt}Published 9th July, 2023.\\ Updated 9th July, 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}{JS Basics}} \tn % Row 0 \SetRowColor{LightBackground} \mymulticolumn{1}{x{5.377cm}}{Falsy ⇒ '', 0, null, undefined, NaN, fals} \tn % Row Count 1 (+ 1) % Row 1 \SetRowColor{white} \mymulticolumn{1}{x{5.377cm}}{var - hoisting, let, const - blocks} \tn % Row Count 2 (+ 1) % Row 2 \SetRowColor{LightBackground} \mymulticolumn{1}{x{5.377cm}}{Temporal Dead Zone начинается в начале области видимости переменной и \seqsplit{заканчивается} ее объявлением} \tn % Row Count 6 (+ 4) % Row 3 \SetRowColor{white} \mymulticolumn{1}{x{5.377cm}}{{\bf{Primitives}}: {\bf{`Undefined}}, {\bf{Boolean, String, Symbol, BigInt, Null}}`} \tn % Row Count 8 (+ 2) \hhline{>{\arrayrulecolor{DarkBackground}}-} \SetRowColor{LightBackground} \mymulticolumn{1}{x{5.377cm}}{{\bf{Non Primotives:}} \newline Object, Array, Function, RegExp, Date, Map, Set, \newline Error, Promise, enum} \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}{Strings}} \tn \SetRowColor{white} \mymulticolumn{1}{x{5.377cm}}{{\bf{`text.length`}} \newline % Row Count 1 (+ 1) {\bf{`text.slice(start, end)`}} =\textgreater{} new string {[}start, end) \newline % Row Count 3 (+ 2) `text.substring(start, end)` new string {[}start, end) \newline % Row Count 5 (+ 2) `text.substr(start, length)` new string {[}start... `length` number of characters. \newline % Row Count 7 (+ 2) `text.replace(oldValue, newValue)` \seqsplit{`text.replaceAll(oldValue}, newValue)` \newline % Row Count 9 (+ 2) `text.toUpperCase()` `text.toLowerCase()` \newline % Row Count 10 (+ 1) `concat(string1, string2, ..., stringN)` \newline % Row Count 11 (+ 1) `text.trim()` `trimStart()` `trimEnd()` \newline % Row Count 12 (+ 1) `padStart(targetLength, padString)`: adds padding to the beginning \newline % Row Count 14 (+ 2) `padEnd(targetLength, padString)`:adds padding to the end \newline % Row Count 16 (+ 2) `charAt(index)` `charCodeAt(index)` \newline % Row Count 17 (+ 1) {\bf{`split(separator, limit)`}}% Row Count 18 (+ 1) } \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}{Timers}} \tn % Row 0 \SetRowColor{LightBackground} \mymulticolumn{1}{x{5.377cm}}{Методы setInterval(func, delay, ...args) и setTimeout(func, delay, ...args) позволяют выполнять func регулярно или только один раз после задержки delay, заданной в мс.} \tn % Row Count 5 (+ 5) % Row 1 \SetRowColor{white} \mymulticolumn{1}{x{5.377cm}}{ля отмены выполнения необходимо вызвать \seqsplit{clearInterval/clearTimeout} со значением, которое возвращают методы setInterval/setTimeout.} \tn % Row Count 9 (+ 4) % Row 2 \SetRowColor{LightBackground} \mymulticolumn{1}{x{5.377cm}}{Планирование с нулевой задержкой setTimeout(func,0) или, что то же самое, setTimeout(func) используется для вызовов, которые должны быть исполнены как можно скорее, после завершения исполнения текущего кода.} \tn % Row Count 16 (+ 7) % Row 3 \SetRowColor{white} \mymulticolumn{1}{x{5.377cm}}{Браузер ограничивает 4-мя мс минимальную задержку между пятью и более вложенными вызовами setTimeout, а также для setInterval, начиная с 5-го вызова.} \tn % Row Count 21 (+ 5) % Row 4 \SetRowColor{LightBackground} \mymulticolumn{1}{x{5.377cm}}{`let timerId = setTimeout(...); clearTimeout(timerId);`} \tn % Row Count 23 (+ 2) \hhline{>{\arrayrulecolor{DarkBackground}}-} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{5.377cm}{X} \SetRowColor{DarkBackground} \mymulticolumn{1}{x{5.377cm}}{\bf\textcolor{white}{Objects}} \tn \SetRowColor{white} \mymulticolumn{1}{x{5.377cm}}{{\bf{Creating Objects}} \newline % Row Count 1 (+ 1) Literal/ Contructor Function/ Class \newline % Row Count 2 (+ 1) `\{x: "y"\}` `(new) function()\{\}` `new Object() same as \{\}` `class Banana \{\}` `Object.create(``proto{[}, propertiesObject{]})` \newline % Row Count 5 (+ 3) {\bf{`delete book.usersReading`}} \newline % Row Count 6 (+ 1) {\bf{Обход объекта}} \newline % Row Count 7 (+ 1) {\bf{`for (let key in myObject)` `Object.entries() =\textgreater{}}} {[}key, value{]}` \newline % Row Count 9 (+ 2) {\bf{`Object.keys()}} ⇒ {[}key{]}` {\bf{`Object.values()}} =\textgreater{}{[}values{]}` \newline % Row Count 11 (+ 2) {\bf{Методы}} \newline % Row Count 12 (+ 1) `someObj.hasOwnProperty{\bf{(}}'key1'{\bf{)`}} \newline % Row Count 13 (+ 1) `obj.\_\_{\bf{proto\_\_}} === person` ⇒ \seqsplit{`Object.getPrototypeOf(object1)`} \seqsplit{`Object.setPrototypeOf(object1)`} \newline % Row Count 16 (+ 3) The {\bf{`valueOf()`}} method of `{[}Object{]}` instances converts the `this` value {[}to an object{]}% Row Count 18 (+ 2) } \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}{Object.create()}} \tn \SetRowColor{LightBackground} \mymulticolumn{1}{x{5.377cm}}{function MyClass() \{ \newline SuperClass.call(this); \newline \seqsplit{OtherSuperClass.call(this);} \newline \} \newline MyClass.prototype = \seqsplit{Object.create(SuperClass.prototype);}} \tn \hhline{>{\arrayrulecolor{DarkBackground}}-} \SetRowColor{LightBackground} \mymulticolumn{1}{x{5.377cm}}{позволяет создавать новый объект и \seqsplit{устанавливать} прототип этого объекта в объект, переданный в качестве параметра} \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}{Events}} \tn % Row 0 \SetRowColor{LightBackground} \mymulticolumn{1}{x{5.377cm}}{Event Phases - это три фазы жизненного цикла события: захват (capturing), цель (target) и всплытие (bubbling).} \tn % Row Count 4 (+ 4) % Row 1 \SetRowColor{white} \mymulticolumn{1}{x{5.377cm}}{Разница между этими фазами заключается в порядке вызова обработчиков событий. В фазе захвата обработчики вызываются сверху вниз, а в фазе всплытия - снизу вверх. В фазе цели вызывается только один обработчик, связанный с элементом цели.} \tn % Row Count 13 (+ 9) % Row 2 \SetRowColor{LightBackground} \mymulticolumn{1}{x{5.377cm}}{Mouse Events: - click - dblclick - mousedown - mouseup - mousemove - mouseover - mouseout - contextmenu} \tn % Row Count 16 (+ 3) % Row 3 \SetRowColor{white} \mymulticolumn{1}{x{5.377cm}}{Keyboard Events: - keydown - keyup - keypress} \tn % Row Count 17 (+ 1) % Row 4 \SetRowColor{LightBackground} \mymulticolumn{1}{x{5.377cm}}{Form: formdata reset submit;} \tn % Row Count 18 (+ 1) % Row 5 \SetRowColor{white} \mymulticolumn{1}{x{5.377cm}}{Input:change, input, cut, copy, paste} \tn % Row Count 19 (+ 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}{Array NOT Mutating}} \tn \SetRowColor{LightBackground} \mymulticolumn{1}{x{5.377cm}}{`concat(array1, array2, ..., arrayN): new Array` \newline `array.filter(callback(el, ind, array), thisArg): new Array` \newline `array.map(callback(elt, ind, array), thisArg): new Array` \newline `array.slice(start, end): new Array` \newline `array.reduce(callback(acc, cur, i, array), initi): any` \newline `reduceRight(callback(acc, cur, i, array), init): any`} \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 Mutations}} \tn \SetRowColor{white} \mymulticolumn{1}{x{5.377cm}}{`push(element1, element2, ..., elementN)` \newline % Row Count 1 (+ 1) `pop()` \newline % Row Count 2 (+ 1) `shift()` \newline % Row Count 3 (+ 1) `unshift(element1, element2, ..., elementN)` \newline % Row Count 4 (+ 1) `splice(start, deleteCount, item1, item2, ..., itemN)` \newline % Row Count 6 (+ 2) `sort(compareFunction)` \newline % Row Count 7 (+ 1) `reverse()` \newline % Row Count 8 (+ 1) `fill(value, start, end)`% Row Count 9 (+ 1) } \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}{Iterate Array}} \tn \SetRowColor{LightBackground} \mymulticolumn{1}{x{5.377cm}}{for (let i = 0; i \textless{} scores.length; i++) \{\} \newline for (i in scores) \{\} \newline for (score of scores) \{\} \newline scores.forEach((score) =\textgreater{} \{\}); \newline every(function (element, index, array) \{ /{\emph{ … }}/ \}, thisArg) \newline array.reduce( function(total, el, i, arr),initialValue ) \newline every(function (element, index, array) \{ /{\emph{ … }}/ \}, thisArg)} \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}{Copy Array}} \tn \SetRowColor{LightBackground} \mymulticolumn{1}{x{5.377cm}}{const arrNew = {[}...arrOld{]}; \newline const newArray = {[}...oldArray{]}; \newline \{ const json = \seqsplit{JSON.stringify(oldArray);} \newline const newArray = JSON.parse(json); \} \newline const arrNew = arrOld.slice(); \newline const arrNew = Array.from(arrOld); \newline const arrNew = {[}{]}.concat(arrOld);} \tn \hhline{>{\arrayrulecolor{DarkBackground}}-} \end{tabularx} \par\addvspace{1.3em} % That's all folks \end{multicols*} \end{document}