<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: Lukasz Pietraszek</title>
    <description>The latest articles on DEV Community by Lukasz Pietraszek (@pietraszek).</description>
    <link>https://dev.to/pietraszek</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F619004%2Fab63a313-abbf-4413-b844-8243092f7b4b.jpg</url>
      <title>DEV Community: Lukasz Pietraszek</title>
      <link>https://dev.to/pietraszek</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/pietraszek"/>
    <language>en</language>
    <item>
      <title>Interview questions: React</title>
      <dc:creator>Lukasz Pietraszek</dc:creator>
      <pubDate>Mon, 31 May 2021 16:38:51 +0000</pubDate>
      <link>https://dev.to/pietraszek/interview-questions-react-42hd</link>
      <guid>https://dev.to/pietraszek/interview-questions-react-42hd</guid>
      <description>&lt;h2&gt;
  
  
  Intro
&lt;/h2&gt;

&lt;p&gt;Welcome to 3rd post from the Interview series. This time I'd like to focus on questions around React and its ecosystem. Since those are interview questions some answers are rather shorter and focusing on the core concepts since during the interview they will try to gauge if you are familiar with them and will try to ask more questions that cover a wider spectrum of your knowledge to see where would you fit in companies structures. If you need to dive into specific subjects there are plenty of articles that cover those concepts in a more granular and extensive way on dev.to or medium.&lt;/p&gt;

&lt;h2&gt;
  
  
  Questions:
&lt;/h2&gt;

&lt;h3&gt;
  
  
  What is virtual DOM and how does React use it to render to the DOM?
&lt;/h3&gt;

&lt;p&gt;React has its own DOM as an object in memory separated from real DOM. Every operation that we make in React are primarily evaluated in this memory version of DOM. Then ReactDOM checks what differences are between memory DOM and real DOM and then updates real DOM with specific changes.&lt;br&gt;
This approach makes it fast because resources are not wasted for interaction with a real browser's DOM and improving performance considerably.&lt;/p&gt;
&lt;h3&gt;
  
  
  What is JSX?
&lt;/h3&gt;

&lt;p&gt;JSX allows us to write HTML or XML-like text code alongside ReactJS by providing syntactic sugar for the &lt;code&gt;React.createElement(component, props, ...children)&lt;/code&gt; function. It has its own extension &lt;code&gt;.jsx&lt;/code&gt; but we can also use it in regular .js files&lt;br&gt;
JSX code:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight jsx"&gt;&lt;code&gt;&lt;span class="p"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nc"&gt;MyButton&lt;/span&gt; &lt;span class="na"&gt;color&lt;/span&gt;&lt;span class="p"&gt;=&lt;/span&gt;&lt;span class="s"&gt;"blue"&lt;/span&gt; &lt;span class="na"&gt;shadowSize&lt;/span&gt;&lt;span class="p"&gt;=&lt;/span&gt;&lt;span class="si"&gt;{&lt;/span&gt;&lt;span class="mi"&gt;2&lt;/span&gt;&lt;span class="si"&gt;}&lt;/span&gt;&lt;span class="p"&gt;&amp;gt;&lt;/span&gt;
  Click Me
&lt;span class="p"&gt;&amp;lt;/&lt;/span&gt;&lt;span class="nc"&gt;MyButton&lt;/span&gt;&lt;span class="p"&gt;&amp;gt;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;compiles to:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight jsx"&gt;&lt;code&gt;&lt;span class="nx"&gt;React&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;createElement&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;MyButton&lt;/span&gt;&lt;span class="p"&gt;,{&lt;/span&gt;&lt;span class="na"&gt;color&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;blue&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="na"&gt;shadowSize&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mi"&gt;2&lt;/span&gt;&lt;span class="p"&gt;},&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;Click Me&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  What problems does React solves?
&lt;/h3&gt;

&lt;p&gt;React lets us create Single Page Applications that resolve the problem of user experience. SPA gives us a desktop-like application experience. We don't have an annoying reloading effect known from traditional web pages every time data is changing.&lt;/p&gt;

&lt;h3&gt;
  
  
  What are the pros and cons of using React?
&lt;/h3&gt;

&lt;p&gt;&lt;strong&gt;Pros:&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Performance and speed enhancement&lt;/li&gt;
&lt;li&gt;Popularity / huge community&lt;/li&gt;
&lt;li&gt;SEO-friendly&lt;/li&gt;
&lt;li&gt;Cost-effectiveness / easy to learn / development time&lt;/li&gt;
&lt;li&gt;Component-Based Architecture&lt;/li&gt;
&lt;li&gt;One direction flow&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Cons:&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Incompleteness - it is just a view part in MVC model&lt;/li&gt;
&lt;li&gt;The high pace of development&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  What is the difference between React and React Native?
&lt;/h3&gt;

&lt;p&gt;React is a library that uses as a default ReactDOM to render content in the browser by changing its DOM. React Native is a cross-platform mobile framework that uses Reactjs for building apps and websites. React Native compiles to native app components enables the programmer to build mobile applications that can run on different platforms such as Windows, Android, iOS in JavaScript.&lt;/p&gt;

&lt;h3&gt;
  
  
  How do you style components in React?
&lt;/h3&gt;

&lt;p&gt;There are at main 4 ways to style React components.&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Inline CSS - Styling React elements using inline CSS allows styles to be completely scoped to an element using a well-understood, standard approach.&lt;/li&gt;
&lt;li&gt;CSS &amp;amp; CSS Pre-processors - This involves using separate stylesheets like our conventional way of styling our HTML websites either with CSS or a CSS preprocessor such as SASS, Less or Stylus.&lt;/li&gt;
&lt;li&gt;CSS-in-JS - Styled-Components - styled-components is a library for React and React Native that allows you to use component-level styles in your application that are written with a mixture of JavaScript and CSS.&lt;/li&gt;
&lt;li&gt;CSS Modules - A CSS Module is a CSS file in which all class names are scoped locally by default.&lt;/li&gt;
&lt;/ol&gt;

&lt;h3&gt;
  
  
  What features were introduced in React 16.x?
&lt;/h3&gt;

&lt;p&gt;With a new React version we have got a few improvements:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;A new type of licence, from now on its MIT, you can use React library for commercial use&lt;/li&gt;
&lt;li&gt;New types returned by render, now you can return string or array of elements&lt;/li&gt;
&lt;li&gt;Portals - it's a new, better way of rendering elements outside the component in which it was created&lt;/li&gt;
&lt;li&gt;Fragments&lt;/li&gt;
&lt;li&gt;Context API&lt;/li&gt;
&lt;li&gt;Lazy&lt;/li&gt;
&lt;li&gt;Hooks&lt;/li&gt;
&lt;li&gt;Better error handling by &lt;code&gt;error boundaries&lt;/code&gt; - components catching and registering errors&lt;/li&gt;
&lt;li&gt;Improvement of Server-Side Rendering&lt;/li&gt;
&lt;li&gt;Files size-reduction - modules of React and react-dom has been reduced by 32%&lt;/li&gt;
&lt;/ol&gt;

&lt;h3&gt;
  
  
  What are Higher Order Components?
&lt;/h3&gt;

&lt;p&gt;Higher-Order Component is an advanced React techniques used when we need to multiply or reuse a component's logic. Components take one or more components as arguments and return a new upgraded component. We don’t modify or mutate components. We create new ones. A HOC is used to compose components for code reuse. A &lt;code&gt;HOC&lt;/code&gt; is a pure function and has no side effects, returning only a new component&lt;/p&gt;

&lt;h3&gt;
  
  
  What are the options to manage state in React?
&lt;/h3&gt;

&lt;p&gt;State management is a way to engender communication and sharing data between components. It creates a concrete data structure that you can read and write and which represents your app's state. A state is a JavaScript object that represents part of the component which can be changed by a user action. We can use Context API or several libraries like &lt;a href="https://redux.js.org/" rel="noopener noreferrer"&gt;Redux&lt;/a&gt;, &lt;a href="https://recoiljs.org/" rel="noopener noreferrer"&gt;Recoil&lt;/a&gt;, we could also use React &lt;code&gt;Hooks&lt;/code&gt;.&lt;/p&gt;

&lt;h3&gt;
  
  
  What's the difference between state and props?
&lt;/h3&gt;

&lt;p&gt;Props (properties) and state are just simple JavaScript objects. Both store pieces of information on how to render a component. Difference between these two objects is major. &lt;code&gt;props&lt;/code&gt; are passed to a component like an arguments to the function while the &lt;code&gt;state&lt;/code&gt; is managed inside a component just like a variable in the function's body.&lt;/p&gt;

&lt;h3&gt;
  
  
  What is prop drilling and how can you avoid it?
&lt;/h3&gt;

&lt;p&gt;Prop drilling is when you passing data through props from top to bottom of the components tree and components don't directly use them. To avoid prop drilling we can use Context API or Render Props.&lt;/p&gt;

&lt;h3&gt;
  
  
  Why React requires key to render the list?
&lt;/h3&gt;

&lt;p&gt;React needs key while rendering lists because it gives React the possibility to distinguish between similar objects in a similar place. When it's up to changing something React by the key can find the exact element that we want to change instead of changing everything that could lead to worse performance. Also in many cases, lack of distinction could cause bugs because React can start interacting with the first found element instead of this one we want it to.&lt;/p&gt;

&lt;h3&gt;
  
  
  How can we improve Accessibility in React?
&lt;/h3&gt;

&lt;p&gt;The ways to improve accessibility in React apps are:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Semantic markup&lt;/li&gt;
&lt;li&gt;Upgrading semantic markup with ARIA (Accessible Rich Internet Applications)&lt;/li&gt;
&lt;li&gt;Using an element's focusing styling&lt;/li&gt;
&lt;li&gt;Keyboard navigation&lt;/li&gt;
&lt;li&gt;Descriptive Alt text for images&lt;/li&gt;
&lt;li&gt;Headings levels&lt;/li&gt;
&lt;li&gt;Labelling forms elements&lt;/li&gt;
&lt;li&gt;Document language&lt;/li&gt;
&lt;li&gt;Fixing contrast ratio&lt;/li&gt;
&lt;/ol&gt;

&lt;h3&gt;
  
  
  What are hooks and why are they useful?
&lt;/h3&gt;

&lt;p&gt;Hooks are functions that contain in themselves actions responsible for the component's state and component's lifecycle methods. With hooks we can now use in stateless components - methods reserved earlier only for classes. Hooks let us keep components layout clear simultaneously with using component's state.&lt;/p&gt;

&lt;h3&gt;
  
  
  What is Redux?
&lt;/h3&gt;

&lt;p&gt;Redux is a library used to manage the application state. React or Angular use Redux to build the user interface. It is a predictable state container for JavaScript applications and is used for the entire application’s state management.&lt;/p&gt;

&lt;h3&gt;
  
  
  What solution would you use to process asynchronous requests with Redux?
&lt;/h3&gt;

&lt;p&gt;Each API call has three base actions associated with it:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;REQUEST &lt;/li&gt;
&lt;li&gt;SUCCESS&lt;/li&gt;
&lt;li&gt;FAIL&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Each of these actions changes the application state and keeps it in line with what is happening during the asynchronous task execution. &lt;/p&gt;

&lt;p&gt;&lt;a href="https://github.com/reduxjs/redux-thunk" rel="noopener noreferrer"&gt;Redux-thunk&lt;/a&gt; middleware allows creating the action's creator returning functions instead of objects.&lt;/p&gt;

&lt;h3&gt;
  
  
  What is Next.js?
&lt;/h3&gt;

&lt;p&gt;&lt;a href="https://nextjs.org/" rel="noopener noreferrer"&gt;Next.js&lt;/a&gt; is a framework that renders sites structure on Server Side. Next.js uses React, Babel and Webpack. Next.js is used for developing single-page JavaScript applications, provides Server Side Rendering SSR which improves the performance of applications loading.&lt;/p&gt;

&lt;h3&gt;
  
  
  How do you test React components?
&lt;/h3&gt;

&lt;p&gt;There are two popular approaches to unit testing React components:&lt;br&gt;
1.&lt;a href="https://enzymejs.github.io/enzyme/" rel="noopener noreferrer"&gt;Enzyme&lt;/a&gt; - is an testing library created by Airbnb where we are testing the component using the state and props of the component. It provides useful functions such as &lt;code&gt;shallow&lt;/code&gt;, &lt;code&gt;mount&lt;/code&gt; or &lt;code&gt;render&lt;/code&gt;. With a shift towards functional components many of Enzyme's methods for testing class instances are no longer useful and for that reason React team recommends using React Testing Library.&lt;br&gt;
2.&lt;a href="https://testing-library.com/docs/react-testing-library/intro/" rel="noopener noreferrer"&gt;react-testing-library&lt;/a&gt; - is an alternative to Enzyme and encourage you to test actual DOM nodes and users interaction with components rather then implementation.&lt;/p&gt;

&lt;h3&gt;
  
  
  What is Jest?
&lt;/h3&gt;

&lt;p&gt;&lt;a href="https://jestjs.io/" rel="noopener noreferrer"&gt;Jest&lt;/a&gt; is a JavaScript unit testing framework created by Facebook based on Jasmine and provides automated mock creation and a &lt;code&gt;jsdom&lt;/code&gt; environment. It's often used for testing components.&lt;/p&gt;

&lt;h3&gt;
  
  
  Useful resources:
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;&lt;a href="https://reactjs.org/docs/" rel="noopener noreferrer"&gt;Official Documentation&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://overreacted.io/" rel="noopener noreferrer"&gt;Blog by Dan Abramov&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;Tutorials by Lee Robinson:&lt;a href="https://masteringnextjs.com/" rel="noopener noreferrer"&gt;Mastering Next JS&lt;/a&gt; and &lt;a href="https://react2025.com/" rel="noopener noreferrer"&gt;React 2025&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;&lt;a href="https://developer.mozilla.org/en-US/docs/Learn/Tools_and_testing/Client-side_JavaScript_frameworks/React_accessibility" rel="noopener noreferrer"&gt;React Accessibility on MDN&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://www.youtube.com/c/naderdabit/" rel="noopener noreferrer"&gt;Nader Dabit on YouTube&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://www.robinwieruch.de/react-testing-library" rel="noopener noreferrer"&gt;React Testing Library Tutorial by Robin Wieruch&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Special thanks to &lt;a href="https://twitter.com/_kolodziejczak" rel="noopener noreferrer"&gt;Marek&lt;/a&gt; and &lt;a href="https://twitter.com/tomciuns" rel="noopener noreferrer"&gt;Tomek&lt;/a&gt; for reviewing this post.&lt;/p&gt;




&lt;p&gt;Photo by &lt;a href="https://unsplash.com/@clemono" rel="noopener noreferrer"&gt;Clem Onojeghuo&lt;/a&gt; on &lt;a href="https://unsplash.com/s/photos/for-hire" rel="noopener noreferrer"&gt;Unsplash&lt;/a&gt;&lt;/p&gt;

</description>
      <category>codenewbie</category>
      <category>react</category>
      <category>beginners</category>
      <category>javascript</category>
    </item>
    <item>
      <title>Interview questions: JavaScript</title>
      <dc:creator>Lukasz Pietraszek</dc:creator>
      <pubDate>Tue, 27 Apr 2021 07:47:02 +0000</pubDate>
      <link>https://dev.to/pietraszek/interview-questions-part-2-javascript-lno</link>
      <guid>https://dev.to/pietraszek/interview-questions-part-2-javascript-lno</guid>
      <description>&lt;p&gt;Welcome to the second post on interview questions. You can read &lt;a href="https://lukaszpietraszek.com/blog/interview-questions-part-1" rel="noopener noreferrer"&gt;previous post&lt;/a&gt; which covers general questions regarding HTML, CSS and some of the accessibility.&lt;/p&gt;

&lt;p&gt;In this post, I'd like to focus on common JavaScript questions and simple code tests you might be given during the interview. Below list is a mix of various questions that allow interviewers to gauge your seniority level. &lt;/p&gt;

&lt;h2&gt;
  
  
  What is an IIFE and why are they used?
&lt;/h2&gt;

&lt;p&gt;IIFE stands for "Immediately-invoked function expression"&lt;/p&gt;

&lt;p&gt;The main reason to use it is to preserve a private scope within your function inside of your JavaScript code you want to make sure that you are not overriding any global variables.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight jsx"&gt;&lt;code&gt;&lt;span class="o"&gt;!&lt;/span&gt;&lt;span class="p"&gt;(()&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="nx"&gt;console&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;log&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;Hello from IIFE!&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;span class="p"&gt;})();&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  List Iteration/loops types
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;for&lt;/li&gt;
&lt;li&gt;while&lt;/li&gt;
&lt;li&gt;do while&lt;/li&gt;
&lt;li&gt;for of&lt;/li&gt;
&lt;li&gt;for in&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Explain hoisting
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;Hoisting is a JavaScript mechanism where variables and function declarations are moved to the top of their scope before code execution.&lt;/li&gt;
&lt;li&gt;Function expressions load only when the interpreter reaches that line of code. So if you try to call a function expression before it's loaded, you'll get an error!&lt;/li&gt;
&lt;li&gt;If you call a function declaration instead, it'll always work, because no code can be called until all declarations are loaded.
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight jsx"&gt;&lt;code&gt;&lt;span class="nf"&gt;hoistedFunction&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt; &lt;span class="c1"&gt;// Hello! I am defined immediately!&lt;/span&gt;
&lt;span class="nf"&gt;notHoistedFunction&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt; &lt;span class="c1"&gt;// ReferenceError: notHoistedFunction is not defined&lt;/span&gt;

&lt;span class="c1"&gt;// Function Decalration&lt;/span&gt;
&lt;span class="kd"&gt;function&lt;/span&gt; &lt;span class="nf"&gt;hoistedFunction&lt;/span&gt; &lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="nx"&gt;console&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;log&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;Hello! I am defined immediately!&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;

&lt;span class="c1"&gt;// Function Expression&lt;/span&gt;
&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;notHoistedFunction&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;function &lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="nx"&gt;console&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;log&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;I am not defined immediately.&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  &lt;strong&gt;List ES6  features&lt;/strong&gt;
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;arrow functions&lt;/li&gt;
&lt;li&gt;classes&lt;/li&gt;
&lt;li&gt;template strings&lt;/li&gt;
&lt;li&gt;destructing - The &lt;strong&gt;destructuring assignment&lt;/strong&gt; syntax is a JavaScript expression that makes it possible to unpack values from arrays, or properties from objects, into distinct variables.&lt;/li&gt;
&lt;li&gt;default value&lt;/li&gt;
&lt;li&gt;spread operator - &lt;strong&gt;Spread syntax&lt;/strong&gt; allows an iterable such as an array expression or string to be expanded in places where zero or more arguments (for function calls) or elements (for array literals) are expected, or an object expression to be expanded in places where zero or more key-value pairs (for object literals) are expected. Example: [...iterableObj, '4', 'five', 6];&lt;/li&gt;
&lt;li&gt;let, const, var&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  List JavaScript data types
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;Number&lt;/li&gt;
&lt;li&gt;String&lt;/li&gt;
&lt;li&gt;Boolean&lt;/li&gt;
&lt;li&gt;Null&lt;/li&gt;
&lt;li&gt;Undefined&lt;/li&gt;
&lt;li&gt;Symbol&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  How JavaScript's runtime works? Describe an event loop mechanism. How many threads JavaScript has?
&lt;/h2&gt;

&lt;p&gt;Javascript runtime consists of a few parts:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Heap&lt;/strong&gt; - a large mostly unstructured region of memory, where variables are allocated&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Call stack&lt;/strong&gt; - where function calls form a stack of &lt;em&gt;frames&lt;/em&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Queue&lt;/strong&gt; - a list of messages to be processed. Each message has an associated function that gets called to handle the message.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Functions from the call stack are executed according to the "First in, first out" rule, meaning that the function on top will be executed first.&lt;/p&gt;

&lt;p&gt;Async actions such as &lt;code&gt;fetch&lt;/code&gt; or &lt;code&gt;setTimeout&lt;/code&gt; are provided by the Web API's, and executed by them, so the thread of the JS runtime can remain unblocked while waiting for the timeout or request to be completed. Completed async actions are being put to the queue and pushed back to the call stack once it's empty. This means that &lt;code&gt;setTimeout&lt;/code&gt; with 0 timeout might not output the result immediately.&lt;/p&gt;

&lt;p&gt;References:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;a href="https://flaviocopes.com/javascript-event-loop/" rel="noopener noreferrer"&gt;https://flaviocopes.com/javascript-event-loop/&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://www.youtube.com/watch?v=8aGhZQkoFbQ&amp;amp;feature=emb_title" rel="noopener noreferrer"&gt;https://www.youtube.com/watch?v=8aGhZQkoFbQ&amp;amp;feature=emb_title&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  What are Web Workers
&lt;/h2&gt;

&lt;p&gt;Web workers are scripts that run in the background without the page needing to wait for it to complete. It can be useful when you have a heavy-cost, slow operation running in your application as it won't block the JS runtime while it's running and allow a user to interact with the page.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://developer.mozilla.org/en-US/docs/Web/API/Web_Workers_API/Using_web_workers" rel="noopener noreferrer"&gt;https://developer.mozilla.org/en-US/docs/Web/API/Web_Workers_API/Using_web_workers&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  What is Closure?
&lt;/h2&gt;

&lt;p&gt;A closure is an inner function that has access to the outer (enclosing) function's variables—scope chain. The closure has three scope chains: &lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;it has access to its own scope (variables defined between its curly brackets)&lt;/li&gt;
&lt;li&gt;it has access to the outer function's variables&lt;/li&gt;
&lt;li&gt;it has access to global variables.
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight jsx"&gt;&lt;code&gt;&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;siteName&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;lukaszpietraszek.com&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

&lt;span class="kd"&gt;function&lt;/span&gt; &lt;span class="nf"&gt;outerFunc&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;title&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;Interview Questions&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

  &lt;span class="kd"&gt;function&lt;/span&gt; &lt;span class="nf"&gt;innerFunc&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; 
    &lt;span class="nx"&gt;console&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;log&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;siteName&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
    &lt;span class="nx"&gt;console&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;log&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;title&lt;/span&gt; &lt;span class="p"&gt;);&lt;/span&gt;
  &lt;span class="p"&gt;}&lt;/span&gt;
  &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="nx"&gt;innerFunc&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;myFunc&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;outerFunc&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt;

&lt;span class="nf"&gt;myFunc&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt;
&lt;span class="c1"&gt;// lukaszpietraszek.com&lt;/span&gt;
&lt;span class="c1"&gt;// Interview Questions&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Difference between var and let
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;code&gt;let&lt;/code&gt; allows you to declare variables that are limited in scope to the block, statement, or expression on which it is used.&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;var&lt;/code&gt; keyword defines a variable globally, or locally to an entire function regardless of block scope.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Difference between map, filter and reduce
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;The &lt;strong&gt;&lt;code&gt;Map&lt;/code&gt;&lt;/strong&gt; object holds key-value pairs and remembers the original insertion order of the keys. A &lt;code&gt;Map&lt;/code&gt; object iterates its elements in insertion order — a &lt;a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/for...of" rel="noopener noreferrer"&gt;for...of&lt;/a&gt; loop returns an array of &lt;code&gt;[key, value]&lt;/code&gt; for each iteration.&lt;/li&gt;
&lt;li&gt;The map() function returns a new array by passing a function over each element in the input array.&lt;/li&gt;
&lt;li&gt;The &lt;strong&gt;&lt;code&gt;filter()&lt;/code&gt;&lt;/strong&gt; method creates a new array with all elements that pass the test implemented by the provided function. A new array with the elements that pass the test. If no elements pass the test, an empty array will be returned.&lt;/li&gt;
&lt;li&gt;Reduce method of the array object is used to reduce the array to one single value The &lt;strong&gt;&lt;code&gt;reduce()&lt;/code&gt;&lt;/strong&gt; method executes a &lt;strong&gt;reducer&lt;/strong&gt; function (that you provide) on each member of the array resulting in a single output value.&lt;/li&gt;
&lt;li&gt;The reducer function takes four arguments: &lt;code&gt;Accumulator&lt;/code&gt; (acc) Current Value (cur) &lt;code&gt;Current Index&lt;/code&gt; (idx), &lt;code&gt;Source Array&lt;/code&gt; (src). Your reducer function's returned value is assigned to the accumulator, whose value is remembered across each iteration throughout the array and ultimately becomes the final, single resulting value.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Explain how prototypal inheritance works
&lt;/h2&gt;

&lt;p&gt;JavaScript only has one construct: objects. Each object has an internal link to another object called its prototype. That prototype object has a prototype of its own, and so on until an object is reached with &lt;code&gt;null&lt;/code&gt; as its prototype. &lt;code&gt;null&lt;/code&gt;, by definition, has no prototype and acts as the final link in this prototype chain.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;The core idea of Prototypal Inheritance is that an object can point to another object and inherit all its properties.&lt;/li&gt;
&lt;li&gt;The main purpose is to allow multiple instances of an object to share common properties, hence, the Singleton Pattern.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Explain Getters and Setters
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;A &lt;code&gt;getter&lt;/code&gt; is a method that gets the value of a specific property. A &lt;code&gt;setter&lt;/code&gt; is a method that sets the value of a specific property. You can define getters and setters on any predefined core object or user-defined object that supports the addition of new properties. The syntax for defining getters and setters uses the object literal syntax.&lt;/li&gt;
&lt;li&gt;A difference between using a getter or setter and using a standard function is that getters/setters are automatically invoked on assignment. So it looks just like a normal property but behind the scenes, you can have extra logic (or checks) to be run just before or after the assignment.
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight jsx"&gt;&lt;code&gt;&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;person&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="na"&gt;firstName&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;John&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="na"&gt;lastName&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;Doe&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="kd"&gt;get&lt;/span&gt; &lt;span class="nf"&gt;fullName&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
        &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="s2"&gt;`&lt;/span&gt;&lt;span class="p"&gt;${&lt;/span&gt;&lt;span class="k"&gt;this&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;firstName&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="s2"&gt; &lt;/span&gt;&lt;span class="p"&gt;${&lt;/span&gt;&lt;span class="k"&gt;this&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;lastName&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="s2"&gt;`&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="p"&gt;},&lt;/span&gt;
    &lt;span class="kd"&gt;set&lt;/span&gt; &lt;span class="nf"&gt;fullName&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;name&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
        &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;words&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;name&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;toString&lt;/span&gt;&lt;span class="p"&gt;().&lt;/span&gt;&lt;span class="nf"&gt;split&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt; &lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
        &lt;span class="k"&gt;this&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;firstName&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;words&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt; &lt;span class="o"&gt;||&lt;/span&gt; &lt;span class="dl"&gt;''&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
        &lt;span class="k"&gt;this&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;lastName&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;words&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt; &lt;span class="o"&gt;||&lt;/span&gt; &lt;span class="dl"&gt;''&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="p"&gt;};&lt;/span&gt;

&lt;span class="nx"&gt;person&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;fullName&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;Mark Smith&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="nx"&gt;console&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;log&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;person&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;fullName&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt; &lt;span class="c1"&gt;// Mark Smith&lt;/span&gt;
&lt;span class="nx"&gt;console&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;log&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;person&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;firstName&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt; &lt;span class="c1"&gt;// Mark&lt;/span&gt;
&lt;span class="nx"&gt;console&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;log&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;person&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;lastName&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="c1"&gt;// Smith&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  What is a callback function?
&lt;/h2&gt;

&lt;p&gt;JavaScript functions as arguments, and can be returned by other functions.&lt;/p&gt;

&lt;p&gt;Functions that do this are called &lt;strong&gt;higher-order functions&lt;/strong&gt;. Any function that is passed as an argument is called a &lt;strong&gt;callback function&lt;/strong&gt;.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight jsx"&gt;&lt;code&gt;&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;allUserData&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;[];&lt;/span&gt;

&lt;span class="kd"&gt;function&lt;/span&gt; &lt;span class="nf"&gt;logStuff&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;userData&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="k"&gt;if &lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="k"&gt;typeof&lt;/span&gt; &lt;span class="nx"&gt;userData&lt;/span&gt; &lt;span class="o"&gt;===&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;string&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="nx"&gt;console&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;log&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;userData&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
  &lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="k"&gt;else&lt;/span&gt; &lt;span class="k"&gt;if &lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="k"&gt;typeof&lt;/span&gt; &lt;span class="nx"&gt;userData&lt;/span&gt; &lt;span class="o"&gt;===&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;object&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="k"&gt;for &lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;item&lt;/span&gt; &lt;span class="k"&gt;in&lt;/span&gt; &lt;span class="nx"&gt;userData&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
      &lt;span class="nx"&gt;console&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;log&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;`&lt;/span&gt;&lt;span class="p"&gt;${&lt;/span&gt;&lt;span class="nx"&gt;item&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="s2"&gt;: &lt;/span&gt;&lt;span class="p"&gt;${&lt;/span&gt;&lt;span class="nx"&gt;userData&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="nx"&gt;item&lt;/span&gt;&lt;span class="p"&gt;]}&lt;/span&gt;&lt;span class="s2"&gt;`&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
    &lt;span class="p"&gt;}&lt;/span&gt;
  &lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;

&lt;span class="kd"&gt;function&lt;/span&gt; &lt;span class="nf"&gt;getInput&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;options&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;callback&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="nx"&gt;allUserData&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;push&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;options&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;

  &lt;span class="k"&gt;if &lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="k"&gt;typeof&lt;/span&gt; &lt;span class="nx"&gt;callback&lt;/span&gt; &lt;span class="o"&gt;===&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;function&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="nf"&gt;callback&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;options&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
  &lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;

&lt;span class="nf"&gt;getInput&lt;/span&gt;&lt;span class="p"&gt;({&lt;/span&gt; &lt;span class="na"&gt;firstName&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;John&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="na"&gt;lastName&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;Doe&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt; &lt;span class="p"&gt;},&lt;/span&gt; &lt;span class="nx"&gt;logStuff&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;span class="c1"&gt;// firstName: John&lt;/span&gt;
&lt;span class="c1"&gt;// lastName: Doe&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  What are Promises
&lt;/h2&gt;

&lt;p&gt;It allows you to associate handlers with an asynchronous action's eventual success value or failure reason. This lets asynchronous methods return values like synchronous methods: instead of immediately returning the final value, the asynchronous method returns a &lt;em&gt;promise&lt;/em&gt; to supply the value at some point.&lt;/p&gt;

&lt;p&gt;A Promise is in one of these states:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;em&gt;pending&lt;/em&gt;: initial state, neither fulfilled nor rejected.&lt;/li&gt;
&lt;li&gt;
&lt;em&gt;fulfilled&lt;/em&gt;: meaning that the operation completed successfully.&lt;/li&gt;
&lt;li&gt;
&lt;em&gt;rejected&lt;/em&gt;: meaning that the operation failed.
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight jsx"&gt;&lt;code&gt;&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;promise&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;new&lt;/span&gt; &lt;span class="nc"&gt;Promise&lt;/span&gt;&lt;span class="p"&gt;((&lt;/span&gt;&lt;span class="nx"&gt;resolve&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;reject&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="k"&gt;if &lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="cm"&gt;/* everything turned out fine */&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="nf"&gt;resolve&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;Stuff worked!&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
  &lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="k"&gt;else&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="nf"&gt;reject&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nc"&gt;Error&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;It broke&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;));&lt;/span&gt;
  &lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="p"&gt;});&lt;/span&gt;

&lt;span class="nx"&gt;promise&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;then&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;
  &lt;span class="nx"&gt;result&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="nx"&gt;console&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;log&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;result&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt; &lt;span class="c1"&gt;// "Stuff worked!"&lt;/span&gt;
  &lt;span class="p"&gt;},&lt;/span&gt;
  &lt;span class="nx"&gt;err&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="nx"&gt;console&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;log&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;err&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt; &lt;span class="c1"&gt;// Error: "It broke"&lt;/span&gt;
  &lt;span class="p"&gt;},&lt;/span&gt;
&lt;span class="p"&gt;);&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Async/Await
&lt;/h2&gt;

&lt;p&gt;An async function is a modification to the syntax used in writing promises. You can call it syntactic sugar over promises. It only makes writing promises easier.&lt;/p&gt;

&lt;p&gt;An async function returns a promise -- if the function returns a value, the promise will be resolved with the value, but if the async function throws an error, the promise is rejected with that value. Let’s see an async function:&lt;/p&gt;

&lt;p&gt;Await is only used with an async function. The await keyword is used in an async function to ensure that all promises returned in the async function are synchronized, ie. they wait for each other. Await eliminates the use of callbacks in .then() and .catch(). In using async and await, async is prepended when returning a promise, await is prepended when calling a promise. try and catch are also used to get the rejection value of an async function. Let's see this with our date example:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight jsx"&gt;&lt;code&gt;&lt;span class="k"&gt;async&lt;/span&gt; &lt;span class="kd"&gt;function&lt;/span&gt; &lt;span class="nf"&gt;myDate&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="k"&gt;try&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="kd"&gt;let&lt;/span&gt; &lt;span class="nx"&gt;dateDetails&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;await&lt;/span&gt; &lt;span class="nx"&gt;date&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="kd"&gt;let&lt;/span&gt; &lt;span class="nx"&gt;message&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;await&lt;/span&gt; &lt;span class="nf"&gt;orderUber&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;dateDetails&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
    &lt;span class="nx"&gt;console&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;log&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;message&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
  &lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="k"&gt;catch &lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;error&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="nx"&gt;console&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;log&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;error&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;message&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
  &lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  What’s the difference between a variable that is: null, undefined or undeclared?
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;Undeclared is any variable that has not been declared yet. Console throws an error for this.&lt;/li&gt;
&lt;li&gt;Undefined is a declared variable that has no assigned value, yet.&lt;/li&gt;
&lt;li&gt;Null is a value that has been assigned to a variable.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  What is Singleton
&lt;/h2&gt;

&lt;p&gt;Singleton is a pattern that allows you to create one instance of an object. If such an instance already exists, you cannot create a second one. Additionally, the initialization of this object takes place only when it is needed in the program. These are the two most important features of this pattern. If a structure lacks both, it is not a singleton. It is best to imagine Singleton as a module (what it will be anyway) that encapsulates the entire mechanism that initializes an instance of that Singleton.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight jsx"&gt;&lt;code&gt;&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;mySingleton&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;(()&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="c1"&gt;// Instance stores a reference to the Singleton&lt;/span&gt;
  &lt;span class="kd"&gt;let&lt;/span&gt; &lt;span class="nx"&gt;instance&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="kd"&gt;function&lt;/span&gt; &lt;span class="nf"&gt;init&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="c1"&gt;// Singleton&lt;/span&gt;
    &lt;span class="c1"&gt;// Private methods and variables&lt;/span&gt;
    &lt;span class="kd"&gt;function&lt;/span&gt; &lt;span class="nf"&gt;privateMethod&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
      &lt;span class="nx"&gt;console&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;log&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;I am private&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
    &lt;span class="p"&gt;}&lt;/span&gt;
    &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;privateVariable&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;Im also private&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
      &lt;span class="c1"&gt;// Public methods and variables&lt;/span&gt;
      &lt;span class="nf"&gt;publicMethod&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
        &lt;span class="nx"&gt;console&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;log&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;The public can see me!&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
      &lt;span class="p"&gt;},&lt;/span&gt;
      &lt;span class="na"&gt;publicProperty&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;I am also public&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="p"&gt;};&lt;/span&gt;
  &lt;span class="p"&gt;}&lt;/span&gt;

  &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="c1"&gt;// Get the Singleton instance if one exists&lt;/span&gt;
    &lt;span class="c1"&gt;// or create one if it doesn't&lt;/span&gt;
    &lt;span class="nf"&gt;getInstance&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
      &lt;span class="k"&gt;if &lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="o"&gt;!&lt;/span&gt;&lt;span class="nx"&gt;instance&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
        &lt;span class="nx"&gt;instance&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;init&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt;
      &lt;span class="p"&gt;}&lt;/span&gt;
      &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="nx"&gt;instance&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="p"&gt;},&lt;/span&gt;
  &lt;span class="p"&gt;};&lt;/span&gt;
&lt;span class="p"&gt;})();&lt;/span&gt;

&lt;span class="c1"&gt;// Usage:&lt;/span&gt;
&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;singleA&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;mySingleton&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;getInstance&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt;
&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;singleB&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;mySingleton&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;getInstance&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt;

&lt;span class="nx"&gt;console&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;log&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;singleA&lt;/span&gt; &lt;span class="o"&gt;===&lt;/span&gt; &lt;span class="nx"&gt;singleB&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt; &lt;span class="c1"&gt;// true&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Scope types
&lt;/h2&gt;

&lt;p&gt;Scope in JavaScript defines what variables you have access to. There are two kinds of scope – global and local scope.&lt;/p&gt;

&lt;p&gt;A local scope can be function scope and block scope.&lt;/p&gt;

&lt;h2&gt;
  
  
  What is the 'this' keyword and how is it used?
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;code&gt;this&lt;/code&gt; always refers to an object.&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;this&lt;/code&gt; refers to an object which calls the function it contains.&lt;/li&gt;
&lt;li&gt;In the global context &lt;code&gt;this&lt;/code&gt; refers to either window object or is undefined if the 'strict mode' is used.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  What Are JavaScript Programming Paradigms?
&lt;/h2&gt;

&lt;p&gt;JavaScript is a multi-paradigm language, supporting imperative/procedural programming along with OOP (Object-Oriented Programming) and functional programming. JavaScript supports OOP with prototypal inheritance.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Prototypal inheritance (also: prototypes, OLOO - Object Linking to Other Objects).&lt;/li&gt;
&lt;li&gt;Functional programming (also: immutability, pure functions, function composing, cursing, closures, first-class functions, lambdas).&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Functional Programming
&lt;/h2&gt;

&lt;p&gt;Functional Programming is a form of programming in which you can pass functions as parameters to other functions and also return them as values. In functional programming, we think and code in terms of functions.&lt;/p&gt;

&lt;h2&gt;
  
  
  Object-Oriented Programming
&lt;/h2&gt;

&lt;p&gt;The basic idea of OOP is that we use objects to model real-world things that we want to represent inside our programs, and/or provide a simple way to access functionality that would otherwise be hard or impossible to make use of.&lt;/p&gt;

&lt;p&gt;Objects can contain related data and code, which represent information about the thing you are trying to model, and the functionality or behaviour that you want it to have. Object data (and often, functions too) can be stored neatly (the official word is &lt;strong&gt;encapsulated&lt;/strong&gt;) inside an object package (which can be given a specific name to refer to, which is sometimes called a &lt;strong&gt;namespace&lt;/strong&gt;), making it easy to structure and access; objects are also commonly used as data stores that can be easily sent across the network.&lt;/p&gt;

&lt;h2&gt;
  
  
  Higher-order functions
&lt;/h2&gt;

&lt;p&gt;A Higher-Order function is a function that receives a function as an argument or returns the function as output.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight jsx"&gt;&lt;code&gt;&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;double&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;n&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="nx"&gt;n&lt;/span&gt; &lt;span class="o"&gt;*&lt;/span&gt; &lt;span class="mi"&gt;2&lt;/span&gt;

&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;2&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;3&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;4&lt;/span&gt;&lt;span class="p"&gt;].&lt;/span&gt;&lt;span class="nf"&gt;map&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;double&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="c1"&gt;// [ 2, 4, 6, 8 ]&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  &lt;strong&gt;What is Object literal syntax?&lt;/strong&gt;
&lt;/h2&gt;

&lt;p&gt;Object literal is a comma-separated list of name-value pairs wrapped in curly braces.&lt;/p&gt;

&lt;p&gt;Object literals encapsulate data, enclosing it in a tidy package.&lt;/p&gt;

&lt;h2&gt;
  
  
  Write Class example in JavaScript
&lt;/h2&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight jsx"&gt;&lt;code&gt;&lt;span class="kd"&gt;class&lt;/span&gt; &lt;span class="nc"&gt;Person&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="nf"&gt;constructor&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;name&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;surname&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="k"&gt;this&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;name&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;name&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="k"&gt;this&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;surname&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;surname&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="p"&gt;}&lt;/span&gt;
  &lt;span class="kd"&gt;get&lt;/span&gt; &lt;span class="nf"&gt;fullName&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="k"&gt;this&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;name&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt; &lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="k"&gt;this&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;surname&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="p"&gt;}&lt;/span&gt;
  &lt;span class="kd"&gt;set&lt;/span&gt; &lt;span class="nf"&gt;fullName&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;name&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="kd"&gt;var&lt;/span&gt; &lt;span class="nx"&gt;words&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;name&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;toString&lt;/span&gt;&lt;span class="p"&gt;().&lt;/span&gt;&lt;span class="nf"&gt;split&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt; &lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
    &lt;span class="k"&gt;this&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;name&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;words&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;];&lt;/span&gt;
    &lt;span class="k"&gt;this&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;surname&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;words&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;];&lt;/span&gt;
  &lt;span class="p"&gt;}&lt;/span&gt;
  &lt;span class="nf"&gt;sayHello&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="nx"&gt;console&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;log&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;`My name is &lt;/span&gt;&lt;span class="p"&gt;${&lt;/span&gt;&lt;span class="k"&gt;this&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;name&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="s2"&gt; &lt;/span&gt;&lt;span class="p"&gt;${&lt;/span&gt;&lt;span class="k"&gt;this&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;surname&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="s2"&gt;`&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
  &lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Determine what would be logged out to the console.
&lt;/h2&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight jsx"&gt;&lt;code&gt;&lt;span class="c1"&gt;// What would be logged out to the console?&lt;/span&gt;
&lt;span class="kd"&gt;var&lt;/span&gt; &lt;span class="nx"&gt;num&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;50&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

&lt;span class="kd"&gt;function&lt;/span&gt; &lt;span class="nf"&gt;logNumber&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="nx"&gt;console&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;log&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;num&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
    &lt;span class="kd"&gt;var&lt;/span&gt; &lt;span class="nx"&gt;num&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;100&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;

&lt;span class="nf"&gt;logNumber&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt;
&lt;span class="c1"&gt;// Undefined&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;





&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight jsx"&gt;&lt;code&gt;&lt;span class="c1"&gt;// When this function is ran in what order the four numbers will be logged out?&lt;/span&gt;
&lt;span class="kd"&gt;function&lt;/span&gt; &lt;span class="nf"&gt;logNumbers&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="nx"&gt;console&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;log&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
  &lt;span class="nf"&gt;setTimeout&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="kd"&gt;function&lt;/span&gt;&lt;span class="p"&gt;(){&lt;/span&gt;&lt;span class="nx"&gt;console&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;log&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;2&lt;/span&gt;&lt;span class="p"&gt;)},&lt;/span&gt; &lt;span class="mi"&gt;1000&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
  &lt;span class="nf"&gt;setTimeout&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="kd"&gt;function&lt;/span&gt;&lt;span class="p"&gt;(){&lt;/span&gt;&lt;span class="nx"&gt;console&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;log&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;3&lt;/span&gt;&lt;span class="p"&gt;)},&lt;/span&gt; &lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
  &lt;span class="nx"&gt;console&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;log&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;4&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;

&lt;span class="nf"&gt;logNumbers&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt;
&lt;span class="c1"&gt;// 1 4 3 2&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;





&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight jsx"&gt;&lt;code&gt;&lt;span class="c1"&gt;// Determine what would be logged out to the console.&lt;/span&gt;
&lt;span class="p"&gt;(()&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;x&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;y&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;100&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="p"&gt;})();&lt;/span&gt;

&lt;span class="nx"&gt;console&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;log&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;y: &lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;y&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;span class="nx"&gt;console&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;log&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;x: &lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;x&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;span class="c1"&gt;// y: 100&lt;/span&gt;
&lt;span class="c1"&gt;// x is not defined&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Write function that checks if the number is prime
&lt;/h2&gt;

&lt;p&gt;A prime number (or a prime) is a natural number greater than 1 that has no positive divisors other than 1 and itself&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight jsx"&gt;&lt;code&gt;&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;isPrime&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;num&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="k"&gt;for&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="kd"&gt;let&lt;/span&gt; &lt;span class="nx"&gt;i&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;2&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="nx"&gt;i&lt;/span&gt; &lt;span class="o"&gt;&amp;lt;&lt;/span&gt; &lt;span class="nx"&gt;num&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="nx"&gt;i&lt;/span&gt;&lt;span class="o"&gt;++&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="k"&gt;if&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;num&lt;/span&gt; &lt;span class="o"&gt;%&lt;/span&gt; &lt;span class="nx"&gt;i&lt;/span&gt; &lt;span class="o"&gt;===&lt;/span&gt; &lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="kc"&gt;false&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="nx"&gt;num&lt;/span&gt; &lt;span class="o"&gt;&amp;gt;&lt;/span&gt; &lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;

&lt;span class="nf"&gt;isPrime&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;5&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="c1"&gt;//true&lt;/span&gt;
&lt;span class="nf"&gt;isPrime&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;6&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="c1"&gt;//false&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  FizzBuzz
&lt;/h2&gt;

&lt;p&gt;Write a program that prints the numbers from 1 to 100. But for multiples of three print “Fizz” instead of the number and the multiples of five print “Buzz”. For numbers that are multiples of both three and five print “FizzBuzz”.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight jsx"&gt;&lt;code&gt;&lt;span class="c1"&gt;// Solution 1&lt;/span&gt;
&lt;span class="k"&gt;for &lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="kd"&gt;let&lt;/span&gt; &lt;span class="nx"&gt;i&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="nx"&gt;i&lt;/span&gt; &lt;span class="o"&gt;&amp;lt;=&lt;/span&gt; &lt;span class="mi"&gt;100&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="nx"&gt;i&lt;/span&gt;&lt;span class="o"&gt;++&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;f&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;i&lt;/span&gt; &lt;span class="o"&gt;%&lt;/span&gt; &lt;span class="mi"&gt;3&lt;/span&gt; &lt;span class="o"&gt;==&lt;/span&gt; &lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;b&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;i&lt;/span&gt; &lt;span class="o"&gt;%&lt;/span&gt; &lt;span class="mi"&gt;5&lt;/span&gt; &lt;span class="o"&gt;==&lt;/span&gt; &lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="nx"&gt;console&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;log&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;f&lt;/span&gt; &lt;span class="p"&gt;?&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;b&lt;/span&gt; &lt;span class="p"&gt;?&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;FizzBuzz&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt; &lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;Fizz&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;b&lt;/span&gt; &lt;span class="p"&gt;?&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;Buzz&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt; &lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;i&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;

&lt;span class="c1"&gt;// Solution 2&lt;/span&gt;
&lt;span class="k"&gt;for &lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="kd"&gt;let&lt;/span&gt; &lt;span class="nx"&gt;i&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="nx"&gt;i&lt;/span&gt; &lt;span class="o"&gt;&amp;lt;=&lt;/span&gt; &lt;span class="mi"&gt;100&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="nx"&gt;i&lt;/span&gt;&lt;span class="o"&gt;++&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="kd"&gt;let&lt;/span&gt; &lt;span class="nx"&gt;res&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="dl"&gt;""&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="k"&gt;if &lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;i&lt;/span&gt; &lt;span class="o"&gt;%&lt;/span&gt; &lt;span class="mi"&gt;3&lt;/span&gt; &lt;span class="o"&gt;===&lt;/span&gt; &lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="nx"&gt;res&lt;/span&gt; &lt;span class="o"&gt;+=&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;Fizz&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="p"&gt;}&lt;/span&gt;
  &lt;span class="k"&gt;if &lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;i&lt;/span&gt; &lt;span class="o"&gt;%&lt;/span&gt; &lt;span class="mi"&gt;5&lt;/span&gt; &lt;span class="o"&gt;===&lt;/span&gt; &lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="nx"&gt;res&lt;/span&gt; &lt;span class="o"&gt;+=&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;Buzz&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="p"&gt;}&lt;/span&gt;
  &lt;span class="nx"&gt;console&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;log&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;res&lt;/span&gt; &lt;span class="o"&gt;||&lt;/span&gt; &lt;span class="nx"&gt;i&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Revers string
&lt;/h2&gt;

&lt;p&gt;Write a function that reverts string&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight jsx"&gt;&lt;code&gt;&lt;span class="c1"&gt;// Solution 1&lt;/span&gt;
&lt;span class="kd"&gt;function&lt;/span&gt; &lt;span class="nf"&gt;revert&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;string&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;_reverted&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;string&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;split&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;""&lt;/span&gt;&lt;span class="p"&gt;).&lt;/span&gt;&lt;span class="nf"&gt;reverse&lt;/span&gt;&lt;span class="p"&gt;().&lt;/span&gt;&lt;span class="nf"&gt;join&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;""&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
  &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="nx"&gt;_reverted&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="nx"&gt;console&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;log&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nf"&gt;revert&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;Lukasz&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;));&lt;/span&gt; &lt;span class="c1"&gt;//zsakuL&lt;/span&gt;

&lt;span class="c1"&gt;// Solution 2&lt;/span&gt;
&lt;span class="kd"&gt;function&lt;/span&gt; &lt;span class="nf"&gt;revertTwo&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;string&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="kd"&gt;let&lt;/span&gt; &lt;span class="nx"&gt;_reverted&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="dl"&gt;""&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="k"&gt;for &lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="kd"&gt;let&lt;/span&gt; &lt;span class="nx"&gt;i&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;string&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;length&lt;/span&gt; &lt;span class="o"&gt;-&lt;/span&gt; &lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="nx"&gt;i&lt;/span&gt; &lt;span class="o"&gt;&amp;gt;=&lt;/span&gt; &lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="nx"&gt;i&lt;/span&gt;&lt;span class="o"&gt;--&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="nx"&gt;_reverted&lt;/span&gt; &lt;span class="o"&gt;+=&lt;/span&gt; &lt;span class="nx"&gt;string&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="nx"&gt;i&lt;/span&gt;&lt;span class="p"&gt;];&lt;/span&gt;
  &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="nx"&gt;_reverted&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;

&lt;span class="nx"&gt;console&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;log&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nf"&gt;revertTwo&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;Interview&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;));&lt;/span&gt; &lt;span class="c1"&gt;//weivretnI&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



</description>
      <category>javascript</category>
      <category>beginners</category>
      <category>webdev</category>
      <category>interview</category>
    </item>
    <item>
      <title>Interview questions: CSS, HTML &amp; Accessibility</title>
      <dc:creator>Lukasz Pietraszek</dc:creator>
      <pubDate>Mon, 26 Apr 2021 08:52:06 +0000</pubDate>
      <link>https://dev.to/pietraszek/interview-questions-part-1-css-html-accessibility-ak9</link>
      <guid>https://dev.to/pietraszek/interview-questions-part-1-css-html-accessibility-ak9</guid>
      <description>&lt;p&gt;In this series of posts, I'll try to cover the most frequent questions I've been asked over past years or questions I ask when interviewing candidates. The level of question ranges from junior to mid-weight devs and is rather a framework agnostic.&lt;/p&gt;

&lt;p&gt;In this part, we will go through some general questions, some CSS related and Accessibility questions. In the next post, we will focus solely on JavaScript questions.&lt;/p&gt;

&lt;p&gt;Without further due let's start.&lt;/p&gt;




&lt;h2&gt;
  
  
  General Questions
&lt;/h2&gt;

&lt;p&gt;A way to start an interview would be to ask about the candidate's past/current role. For example:&lt;/p&gt;

&lt;h3&gt;
  
  
  Tell me about your past/current role - what do you do?
&lt;/h3&gt;

&lt;p&gt;At that point, the interviewer will take few notes and check if the candidate mentions keywords that you can ask more about later, ex: pre-processor, &lt;a href="https://webpack.js.org/" rel="noopener noreferrer"&gt;Webpack&lt;/a&gt; etc. Also, they will validate if what the candidate is saying is in fact listed in the CV.&lt;/p&gt;

&lt;p&gt;So make sure that you are upfront and honest with the person who interviews you. It may sound silly but before each interview read your own CV and make sure you know answers to all keywords and aspects mentioned there.&lt;/p&gt;

&lt;p&gt;Next, you might be asked:&lt;/p&gt;

&lt;h3&gt;
  
  
  What is the typical workflow from the point you get a task to its completion?
&lt;/h3&gt;

&lt;p&gt;or&lt;/p&gt;

&lt;h3&gt;
  
  
  What tools and techniques do you use?
&lt;/h3&gt;

&lt;p&gt;Here you can refer to your day-to-day job. The more you have to say here the better. Use this time to talk about your own findings, experiences, and suggestions on how to improve them. You might want to use this time to talk a little bit about the side projects you are working on, the ideas for new apps, etc. It will show you are passionate about technology and in case you don't have much commercial experience in setup used in the role you are open-minded and always willing to learn new things. Use this time wisely to your advantage.&lt;/p&gt;

&lt;p&gt;Then interviewer might follow up with: &lt;/p&gt;

&lt;h3&gt;
  
  
  I can see you wrote you have been working with VueJS, can you elaborate a bit on it?
&lt;/h3&gt;

&lt;p&gt;and &lt;/p&gt;

&lt;h3&gt;
  
  
  Have you used any other libraries or just this one?
&lt;/h3&gt;

&lt;p&gt;Of course, it all depends on your level of confidence and experience. But again if you are a junior don't try to hide it from interviewers. If you are a senior don't brag. Talk with passion about each subject but try to be modest. Show you know technical aspects but don't dive into too many details. This is just a warm-up before more detailed questions and you can rest assured your time to shine will come at a later stage of the interview :)&lt;/p&gt;

&lt;h3&gt;
  
  
  How do you stay up to date with the latest technology changes?
&lt;/h3&gt;

&lt;p&gt;You are going to mention websites, books, Twitter, podcasts, etc&lt;/p&gt;

&lt;h3&gt;
  
  
  What tools do you use for cross-browser testing?
&lt;/h3&gt;

&lt;p&gt;Your answer should include some of the following options: &lt;a href="https://www.browserstack.com/" rel="noopener noreferrer"&gt;BrowserStack&lt;/a&gt;, &lt;a href="https://crossbrowsertesting.com/" rel="noopener noreferrer"&gt;CrossBrowserTesting&lt;/a&gt;, Virtual Machines (eg: &lt;a href="https://www.virtualbox.org/" rel="noopener noreferrer"&gt;Virtual Box&lt;/a&gt;), different devices: phones, computers, laptops&lt;/p&gt;




&lt;h2&gt;
  
  
  HTML/CSS questions
&lt;/h2&gt;

&lt;h3&gt;
  
  
  How we can optimize site loading time?
&lt;/h3&gt;

&lt;p&gt;Your answers will be around&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;minify code: JS, CSS HTML&lt;/li&gt;
&lt;li&gt;load JS in the footer &lt;/li&gt;
&lt;li&gt;image optimization - etc do not load bigger images than needed - asynchronous loading&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  How do you prevent errors in JS and CSS?
&lt;/h3&gt;

&lt;p&gt;Answer: &lt;a href="https://jslint.com/" rel="noopener noreferrer"&gt;JSLint&lt;/a&gt; / &lt;a href="https://jshint.com/" rel="noopener noreferrer"&gt;JSHint&lt;/a&gt;, &lt;a href="http://csslint.net/" rel="noopener noreferrer"&gt;CSSLint&lt;/a&gt;, &lt;a href="https://prettier.io/" rel="noopener noreferrer"&gt;Prettier&lt;/a&gt;, &lt;a href="https://typicode.github.io/husky/" rel="noopener noreferrer"&gt;pre-commit hooks&lt;/a&gt;,  etc&lt;/p&gt;

&lt;h3&gt;
  
  
  What units do you use px, em, or rem?
&lt;/h3&gt;

&lt;p&gt;You need to know the difference between those three and pros and cons of using one or another. But basically what you need to know is &lt;/p&gt;

&lt;p&gt;Pixel (&lt;code&gt;px&lt;/code&gt;) is a commonly used CSS unit on websites. &lt;code&gt;px&lt;/code&gt; is not scalable, it is an absolute unit. Change in the value of another element does not affect the value of absolute units. The value assigned is fixed irrespective of the user setting.&lt;/p&gt;

&lt;p&gt;Element (&lt;code&gt;em&lt;/code&gt;) and Root element (&lt;code&gt;rem&lt;/code&gt;) are responsive units interpreted into equivalent px unit by the browser. They are relative units. Change in the value of the parent or root element affects the value of relative units.&lt;/p&gt;

&lt;h3&gt;
  
  
  Name some of the commonly used pre-processor and what are the advantages/disadvantages of using CSS pre-processors?
&lt;/h3&gt;

&lt;p&gt;Suggested answers will around the following points&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;a href="http://lesscss.org/" rel="noopener noreferrer"&gt;Less&lt;/a&gt;, &lt;a href="https://sass-lang.com/" rel="noopener noreferrer"&gt;Sass&lt;/a&gt;, &lt;a href="https://stylus-lang.com/" rel="noopener noreferrer"&gt;Stylus&lt;/a&gt;, &lt;a href="https://postcss.org/" rel="noopener noreferrer"&gt;PostCSS&lt;/a&gt; &lt;/li&gt;
&lt;li&gt;In Less &lt;code&gt;@&lt;/code&gt; symbol is used to declare variables, however, &lt;code&gt;@&lt;/code&gt;symbol has already meaning in CSS for example &lt;code&gt;@media&lt;/code&gt; or &lt;code&gt;@keyframes&lt;/code&gt;
&lt;/li&gt;
&lt;li&gt;To compile &lt;code&gt;Sass&lt;/code&gt; you need either Ruby or &lt;a href="https://sass-lang.com/libsass" rel="noopener noreferrer"&gt;libSass&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;the biggest challenge in using pre-processors on projects is the initial time spend to set them up&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  What is the 'Box Model' in CSS?
&lt;/h3&gt;

&lt;p&gt;In CSS, the term "box model" is used when talking about design and layout. The CSS box model is essentially a box that wraps around every HTML element. It consists of: margins, borders, padding, and the actual content.&lt;/p&gt;

&lt;h3&gt;
  
  
  What's the difference between "resetting" and "normalizing" CSS? Which would you choose, and why?
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;Every browser has its own default 'user agent' stylesheet, that it uses to make unstyled websites appear more legible. A CSS Reset (or “Reset CSS”) is a short, often compressed (minified) set of CSS rules that reset the styling of all HTML elements to a consistent baseline. &lt;/li&gt;
&lt;li&gt;
&lt;a href="http://necolas.github.io/normalize.css/" rel="noopener noreferrer"&gt;Normalize&lt;/a&gt; you might call a CSS reset alternative. Instead of wiping out all styles, it delivers a set of reasonable defaults. It doesn't unset things that are already consistent across browsers and reasonable (e.g. bold headers). In that way, organize it does some less than a reset. It also does some more than a reset in that it handles quirks you may never consider, like HTML5 audio element inconsistencies or line-height inconsistencies when you use sub and sup elements.&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  How do you organise your CSS - Namespace patterns?
&lt;/h3&gt;

&lt;p&gt;Mentioning &lt;a href="https://yandex.com/dev/bem/" rel="noopener noreferrer"&gt;BEM&lt;/a&gt;, &lt;a href="http://smacss.com/" rel="noopener noreferrer"&gt;Smacss&lt;/a&gt;, &lt;a href="https://en.wikipedia.org/wiki/OOCSS" rel="noopener noreferrer"&gt;OOCSS&lt;/a&gt;, &lt;a href="https://acss.io/" rel="noopener noreferrer"&gt;Atomic&lt;/a&gt; will do the trick. Make sure that you know not only what each abbreviation means but also syntax and give a real live example of a component/module that could benefit from following those patterns.&lt;/p&gt;




&lt;h2&gt;
  
  
  Accessibility
&lt;/h2&gt;

&lt;h3&gt;
  
  
  How can we improve form accessibility?
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;surround a group of radio buttons in &lt;code&gt;&amp;lt;fieldset&amp;gt;&lt;/code&gt; and add &lt;code&gt;&amp;lt;legend&amp;gt;&lt;/code&gt;,&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;select&lt;/code&gt; tag to have a label, in case many options we could group them using &lt;/li&gt;
&lt;li&gt;input field should have &lt;code&gt;&amp;lt;label&amp;gt;&lt;/code&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  List some of the Aria roles and explain when would you use them
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;code&gt;aria-labeledby&lt;/code&gt; - Example multiple inputs describe by the same label. For instance, in the table it can have multiple labels - &lt;code&gt;aria-describedby&lt;/code&gt; - used to add more info to inputs eg. used in tooltips&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;aria-label&lt;/code&gt; - contains text directly and will overwrite  use when text label is not available&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  How else would you improve site accessibility?
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;by using correct HTML syntax&lt;/li&gt;
&lt;li&gt;correctly use headings h1, h2 .. h6&lt;/li&gt;
&lt;li&gt;use appropriate contrast to make the text on site visible&lt;/li&gt;
&lt;/ul&gt;




&lt;h2&gt;
  
  
  Useful resources
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;a href="https://www.toptal.com/css/interview-questions" rel="noopener noreferrer"&gt;5 Essential CSS Interview Questions&lt;/a&gt; by TopTal&lt;/li&gt;
&lt;li&gt;
&lt;a href="https://css-tricks.com/interview-questions-css/" rel="noopener noreferrer"&gt;Interview Questions and Exercises About CSS&lt;/a&gt; by CSS-tricks - old but valid in most cases38 &lt;/li&gt;
&lt;li&gt;
&lt;a href="https://www.indeed.com/career-advice/interviewing/css-interview-questions-and-answers" rel="noopener noreferrer"&gt;CSS Interview Questions and Answers&lt;/a&gt; by Indeed&lt;/li&gt;
&lt;li&gt;
&lt;a href="https://developer.mozilla.org/en-US/docs/Web/Accessibility" rel="noopener noreferrer"&gt;Accessibility&lt;/a&gt; by MDN&lt;/li&gt;
&lt;li&gt;
&lt;a href="https://clubmate.fi/oocss-acss-bem-smacss-what-are-they-what-should-i-use" rel="noopener noreferrer"&gt;OOCSS, ACSS, BEM, SMACSS: what are they? What should I use?&lt;/a&gt; by Clubmate&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Summary
&lt;/h2&gt;

&lt;p&gt;This is definitely not the full list of questions around HTML/CSS/Accessibility or performance but at least it should give you an idea of what to expect and how to prepare for the interview. &lt;br&gt;
Some questions might sound outdated but in my opinion those are absolute basics that every UI, frontend developer should know the answers too.&lt;/p&gt;

&lt;p&gt;In the next post, I'll cover framework free JavaScript-related questions. &lt;/p&gt;

&lt;p&gt;Take care.&lt;/p&gt;

</description>
      <category>css</category>
      <category>interview</category>
      <category>webdev</category>
      <category>beginners</category>
    </item>
    <item>
      <title>Rise of headless CMS &amp; modern storefronts</title>
      <dc:creator>Lukasz Pietraszek</dc:creator>
      <pubDate>Fri, 23 Apr 2021 08:04:17 +0000</pubDate>
      <link>https://dev.to/pietraszek/rise-of-headless-cms-modern-storefronts-4kbo</link>
      <guid>https://dev.to/pietraszek/rise-of-headless-cms-modern-storefronts-4kbo</guid>
      <description>&lt;p&gt;I've been using headless CMS for over 4 years now in particular at my company we used &lt;a href="https://amplience.com/" rel="noopener noreferrer"&gt;Amplience&lt;/a&gt;. Initially, we used it to create a t-shirt customization component for one of the Premier League football clubs and host product images. For another client of ours, we've built a component that was a bed configurator to visually present how the end product - with all the options such as size, material, finish etc selected - will look like. In both cases, the entire frontend was done using Handlebars, JS and CSS that was integrated within our main app (Hybris) and used data that was provided there to fetched assets (SVG and PNG) from Amplience and displayed them on the storefront.&lt;/p&gt;

&lt;p&gt;Within time our implementation evolved and become more complex. We still used SAP Hybris CMS to provide products related data (e.g. prices) but now more and more UI components such as carousels, accordions, video components and other reusable components were coming directly from Amplience either as HTML or JSON. For clients UI offered by Amplience was more intuitive and easier to get their heads around than what offered by Hybris.&lt;/p&gt;

&lt;p&gt;This is when I realised that this is a direction frontend that will evolve towards to. Within our frontend team, we have decided that all our components should be reusable across different projects but also should remain CMS agnostic.&lt;/p&gt;

&lt;p&gt;When I heard that SAP is working on &lt;a href="https://github.com/SAP/spartacus" rel="noopener noreferrer"&gt;Spartacus&lt;/a&gt; - a storefront framework based on Angular - I was super excited and couldn't wait to try it out.&lt;br&gt;
In fact, I had the privilege to work on one of the first Spartacus integration for the high street beauty brand. I must admit it was challenging. The new storefront (Spartacus) which is based on a framework (Angular) had a steep learning curve, poor documentation and lack of a wider community around it. All of this didn't make things any easier.&lt;/p&gt;

&lt;p&gt;Now looking at how &lt;a href="https://www.vuestorefront.io/" rel="noopener noreferrer"&gt;VueStorefront&lt;/a&gt; (VS for short) which is another storefront to integrate with CMS approaches a market let me be optimistic about the future of frontend integrations. The VueStorefront was initially developed by the same company responsible for Spartacus and only recently become an independent company. Lesson learned from working on Spartacus and bringing it into the market must have an impact on how guys decided to introduce VueStorefront to the world.&lt;/p&gt;

&lt;p&gt;Guys behind VS built a community around it, involved other System Integrators, joined Mach Alliance and what is most important they opened for other CMS as opposed to focusing purely on single CMS as done by Spartacus team.&lt;/p&gt;

&lt;p&gt;Getting started with  VueStroeftont is quite easy. You can spin up your local environment and use &lt;a href="https://docs.vuestorefront.io/storyblok/" rel="noopener noreferrer"&gt;Storyblok&lt;/a&gt; which is free alternatively you can use &lt;a href="https://docs.vuestorefront.io/v2/general/installation.html#using-cli" rel="noopener noreferrer"&gt;CommerceTools&lt;/a&gt; which has 60 days free trial. &lt;/p&gt;

&lt;p&gt;Reading above you might think I'm somehow related to the companies I just mentioned above. But I'm not. I'm just a passionate frontend developer who aims to provide the best values to clients but most importantly to end users - meaning all of us who use the eCommerce platforms on daily basis.&lt;/p&gt;

&lt;h2&gt;
  
  
  Useful resources
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;&lt;a href="https://github.com/SAP/spartacus" rel="noopener noreferrer"&gt;Spartacus&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://www.vuestorefront.io/" rel="noopener noreferrer"&gt;VueStorefront&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://typescript.nuxtjs.org/" rel="noopener noreferrer"&gt;Nuxt TS&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;P.S.&lt;br&gt;
All we need now is a Storefront based on NextJS :)&lt;/p&gt;

</description>
      <category>vue</category>
      <category>javascript</category>
      <category>webdev</category>
      <category>programming</category>
    </item>
  </channel>
</rss>
