<?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>Forem: S. M.  Mahmudur Rahman</title>
    <description>The latest articles on Forem by S. M.  Mahmudur Rahman (@mahmudurbd).</description>
    <link>https://forem.com/mahmudurbd</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%2F775009%2Ff5d9a055-0281-4620-be7f-e9d00e3f38c6.png</url>
      <title>Forem: S. M.  Mahmudur Rahman</title>
      <link>https://forem.com/mahmudurbd</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://forem.com/feed/mahmudurbd"/>
    <language>en</language>
    <item>
      <title>Optimized Toggle Visibility</title>
      <dc:creator>S. M.  Mahmudur Rahman</dc:creator>
      <pubDate>Tue, 18 Jun 2024 16:53:47 +0000</pubDate>
      <link>https://forem.com/mahmudurbd/optimized-toggle-visibility-14k8</link>
      <guid>https://forem.com/mahmudurbd/optimized-toggle-visibility-14k8</guid>
      <description>&lt;p&gt;&lt;a href="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fath5smqewaxmtwer0nzf.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fath5smqewaxmtwer0nzf.png" alt="Image description" width="800" height="240"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h4&gt;
  
  
  Case 1
&lt;/h4&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;&amp;lt;i onClick={() =&amp;gt; setVisible(!visible)} 
className="fi fi-rr-eye absolute top-10 right-3"&amp;gt;
&amp;lt;/i&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h4&gt;
  
  
  Case 2
&lt;/h4&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;&amp;lt;i
onClick={() =&amp;gt; setVisible((currentVal) =&amp;gt; !currentVal)}
className="fi fi-rr-eye absolute top-10 right-3"
&amp;gt;&amp;lt;/i&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Both of the provided &lt;code&gt;onClick&lt;/code&gt; handlers in your  elements are functionally similar and will work correctly. However, they have slight differences in terms of readability and potential optimizations.&lt;/p&gt;

&lt;h4&gt;
  
  
  For Case 1:
&lt;/h4&gt;

&lt;ul&gt;
&lt;li&gt;This directly toggles the &lt;code&gt;visible&lt;/code&gt;state using the current value of &lt;code&gt;visible&lt;/code&gt;.&lt;/li&gt;
&lt;li&gt;If &lt;code&gt;visible&lt;/code&gt;is managed in a parent component, this can lead to stale closures because the &lt;code&gt;visible&lt;/code&gt;value might not be the most up-to-date value at the time of execution.&lt;/li&gt;
&lt;/ul&gt;

&lt;h4&gt;
  
  
  For Case 2:
&lt;/h4&gt;

&lt;ul&gt;
&lt;li&gt;This uses the functional form of the state setter, which ensures that the state update is based on the most recent state value, even if the component re-renders before the state is updated.&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  Recommendation:
&lt;/h3&gt;

&lt;p&gt;The second handler is generally more optimized and is the recommended approach because it leverages the functional update form. This method ensures that you always get the latest state value, avoiding potential issues with stale state closures.&lt;/p&gt;

&lt;p&gt;Here's the recommended version:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;&amp;lt;i
  onClick={() =&amp;gt; setVisible((currentVal) =&amp;gt; !currentVal)}
  className="fi fi-rr-eye absolute top-10 right-3"
&amp;gt;&amp;lt;/i&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Explanation:
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Stale Closures&lt;/strong&gt;: In the first handler, if the component re-renders between the time the onClick is set up and the time it is executed, the visible value might be outdated, leading to unexpected behavior. The second handler avoids this by using the current state value directly.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Readability&lt;/strong&gt;: The second handler is more explicit about its intent to toggle the state based on the current state, making the code easier to understand and maintain.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

</description>
      <category>webdev</category>
      <category>programming</category>
      <category>javascript</category>
      <category>react</category>
    </item>
    <item>
      <title>Backend Concepts</title>
      <dc:creator>S. M.  Mahmudur Rahman</dc:creator>
      <pubDate>Sat, 05 Mar 2022 13:30:39 +0000</pubDate>
      <link>https://forem.com/mahmudurbd/backend-concepts-111n</link>
      <guid>https://forem.com/mahmudurbd/backend-concepts-111n</guid>
      <description>&lt;p&gt;&lt;strong&gt;What is Nodejs? Difference between Nodejs and javaScript&lt;br&gt;
   Or is Node js blocking or non-blocking?&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Ans: Node.js is an extremely powerful framework developed on Chrome’s V8 JavaScript engine that compiles the JavaScript directly into the native machine code. It works on a single-threaded event loop and a non-blocking I/O which provides high rate as it can handle a higher number of concurrent requests.&lt;/p&gt;

&lt;p&gt;It is a lightweight framework used for creating server-side web applications and extends JavaScript API to offer usual server-side functionalities. It is generally used for large-scale application development, especially for video streaming sites, single page application, and other web applications.&lt;/p&gt;

&lt;p&gt;Difference between Nodejs and javaScript is given below:&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;JavaScript&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Programming Language&lt;/li&gt;
&lt;li&gt;Used for any client-side activity for a web application&lt;/li&gt;
&lt;li&gt;Spider monkey (FireFox), JavaScript Core (Safari), V8 (Google Chrome), etc. are running engine&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Node.js&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Interpreter and environment for JavaScript&lt;/li&gt;
&lt;li&gt;Used for accessing or performing any non-blocking operation of any operating system &lt;/li&gt;
&lt;li&gt;V8 (Google Chrome) is running engine&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;How does Node.js work?&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Ans: &lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fefzkjxf4ri2knsv18u10.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fefzkjxf4ri2knsv18u10.png" alt="Image description" width="800" height="370"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Clients send requests to the webserver to interact with the web application. Requests can be non-blocking or blocking:&lt;/li&gt;
&lt;li&gt;Querying for data&lt;/li&gt;
&lt;li&gt;Deleting data &lt;/li&gt;
&lt;li&gt;Updating the data&lt;/li&gt;
&lt;li&gt;Node.js retrieves the incoming requests and adds those to the Event Queue&lt;/li&gt;
&lt;li&gt;The requests are then passed one-by-one through the Event Loop. It checks if the requests are simple enough not to require any external resources&lt;/li&gt;
&lt;li&gt;The Event Loop processes simple requests (non-blocking operations), such as I/O Polling, and returns the responses to the corresponding clients&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;A single thread from the Thread Pool is assigned to a single complex request. This thread is responsible for completing a particular blocking request by accessing external resources, such as computation, database, file system, etc.&lt;/p&gt;

&lt;p&gt;Once the task is carried out completely, the response is sent to the Event Loop that sends that response back to the client.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;What are the differences between SQL and NoSQL database?&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Ans: Differences between sql and nosql database are given below:&lt;br&gt;
&lt;strong&gt;SQL&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Databases are categorized as Relational Database Management System (RDBMS).&lt;/li&gt;
&lt;li&gt;SQL databases display data in form of tables so it is known as table-based database.&lt;/li&gt;
&lt;li&gt;SQL databases are vertically scalable&lt;/li&gt;
&lt;li&gt;SQL databases are best suited for complex queries.&lt;/li&gt;
&lt;li&gt;MySQL, Oracle, Sqlite, PostgreSQL and MS-SQL etc. are the example of SQL database&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;NoSQL&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;NoSQL databases are categorized as Non-relational or distributed database system.&lt;/li&gt;
&lt;li&gt;NoSQL databases display data as collection of key-value pair, documents, graph databases or wide-column stores.&lt;/li&gt;
&lt;li&gt;NoSQL databases are horizontally scalable.&lt;/li&gt;
&lt;li&gt;NoSQL databases are best suited for hierarchical data storage.&lt;/li&gt;
&lt;li&gt;MongoDB, BigTable, Redis, RavenDB, Cassandra, Hbase, Neo4j, CouchDB etc. are the example of nosql database &lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Explain the concept of middleware in Node.js?&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Ans: In general, middleware is a function receives the Request and Response objects. In other words, in an application’s request-response cycle these functions have access to various request &amp;amp;  response objects along with the next function of the cycle. The next function of middleware is represented with the help of a variable, usually named next. Most commonly performed tasks by the middleware functions are:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Execute any type of code&lt;/li&gt;
&lt;li&gt;Update or modify the request and the response objects&lt;/li&gt;
&lt;li&gt;Finish the request-response cycle&lt;/li&gt;
&lt;li&gt;Invoke the next middleware in the stack&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;What is ExpressJS?&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Ans: Express is a minimal and flexible Node.js web application framework that provides a robust set of features for web and mobile applications.&lt;/p&gt;

</description>
      <category>node</category>
      <category>mongodb</category>
      <category>express</category>
    </item>
    <item>
      <title>React JS Concept</title>
      <dc:creator>S. M.  Mahmudur Rahman</dc:creator>
      <pubDate>Sat, 05 Mar 2022 11:52:48 +0000</pubDate>
      <link>https://forem.com/mahmudurbd/react-js-concept-222m</link>
      <guid>https://forem.com/mahmudurbd/react-js-concept-222m</guid>
      <description>&lt;p&gt;&lt;strong&gt;What is reactjs? Tell us about advantages and disadvantages of using react js.&lt;/strong&gt;&lt;br&gt;
  &lt;strong&gt;Or Why will you select ReactJS?&lt;/strong&gt;&lt;br&gt;
  &lt;strong&gt;Or there are so many different javascript frameworks. Why will you use ReactJS for your application?&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Ans: React is a front-end JavaScript library developed by Facebook in 2011. It follows the component based approach which helps in building reusable UI components and is used for developing complex and interactive web and mobile UI.&lt;/p&gt;

&lt;p&gt;Some of the major advantages of React are&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Reusable components&lt;/li&gt;
&lt;li&gt;Virtual DOM helps to make changes to small component without interfering with the whole application&lt;/li&gt;
&lt;li&gt;One-way data flow (Unidirectional) that prevents the app from being unstable&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Disadvantages of React are listed below:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Lack of proper documentation due to fast-changing and update in React&lt;/li&gt;
&lt;li&gt;Its library is very large and takes time to understand&lt;/li&gt;
&lt;li&gt;For new developer Coding gets complex due to JSX&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;How does React Work?&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Ans: Instead of manipulating the browser's DOM directly, React creates a virtual DOM in memory, where it does all the necessary manipulating, before making the changes in the browser DOM. React finds out what changes have been made, and changes only what needs to be changed.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;What is React Component?&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Ans: Components are like functions that return HTML elements.&lt;/p&gt;

&lt;p&gt;*&lt;em&gt;What is props? *&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;Ans: The way of handling component properties is called Props. Props are like function arguments, and send them into the component as attributes.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;What is hook?&lt;/strong&gt;&lt;br&gt;
Ans: Hooks are reusable functions. Hooks allow function components to have access to React features such as state and lifecycle methods.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;What is useState hook?&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Ans: useState Hook allows to track state in a function component. So we can say that State generally refers to data or properties that need to be tracked in an application.&lt;/p&gt;

&lt;p&gt;useState accepts an initial state and returns two values:&lt;br&gt;
const [current state, function that update the state] = useState (initial state)&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;What is useEffect?&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Ans: useEffect Hook allows to perform side effects(fetching data, directly updating the DOM, and timers etc.) in a component.&lt;/p&gt;

&lt;p&gt;useEffect accepts two arguments. The second argument is optional.&lt;br&gt;
useEffect (, )&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;What is useContext hook?&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Ans: useContext hook is a way to manage state globally. With useState it is used to share data between deeply nested component more easily than useState alone.&lt;/p&gt;

&lt;p&gt;Without Context, we will need to pass the state as "props" through each nested componen that may be not needed in that components.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;What is JSX? How does it work?&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Ans: JSX stands for JavaScript XML and It allows us to write HTML inside JavaScript and place them in the DOM without using appendChild( ) or createElement( ) method. Actually JSX provides syntactic sugar for React.createElement( ) function.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;What is Virtual dom? What are the differences between virtual and real dom?&lt;/strong&gt;&lt;br&gt;
   &lt;strong&gt;Or what is the diff algorithm? How does it work?&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Ans: In simple words, virtual DOM is just a copy of the original DOM. React creates a virtual DOM in its memory&lt;/p&gt;

&lt;p&gt;When there is an update in the virtual DOM, React compares the virtual DOM with a snapshot of the virtual DOM taken right before the update of the virtual DOM. With the help of this comparison React figures out which components in the UI need to be updated. &lt;/p&gt;

&lt;p&gt;This process is called diffing. The algorithm that is used for the diffing process is called the diffing algorithm. Once React knows which components have been updated, then it replaces the original DOM nodes with the updated DOM node.&lt;/p&gt;

&lt;p&gt;The difference between virtual and real DOM are listed below&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Real DOM&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;It updates slow.&lt;/li&gt;
&lt;li&gt;Can directly update HTML.&lt;/li&gt;
&lt;li&gt;DOM manipulation is very expensive.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Virtual DOM&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;It updates faster.&lt;/li&gt;
&lt;li&gt;Can’t directly update HTML.&lt;/li&gt;
&lt;li&gt;DOM manipulation is very easy.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Differences between props and state?&lt;br&gt;
  Or How will you pass data from parent to child&lt;br&gt;
  Or Can you change props?&lt;br&gt;
  Or is Props readonly?&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Ans: Props is the shorthand for Properties in React. The way of handling component properties is called Props. Props are like function arguments, and send them into the component as attributes. &lt;br&gt;
They are read-only components that must be immutable. Props are always passed down from the parent to the child components throughout the application. &lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Props&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Data push in HTML is called properties or props&lt;/li&gt;
&lt;li&gt;Props are immutable.&lt;/li&gt;
&lt;li&gt;Props can be accessed by the child component.&lt;/li&gt;
&lt;li&gt;The stateless component can have Props.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;State&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Changing something on website is called states&lt;/li&gt;
&lt;li&gt;State is mutable&lt;/li&gt;
&lt;li&gt;State cannot be accessed by child components.&lt;/li&gt;
&lt;li&gt;The stateless components cannot have State.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;What is the purpose of useState? When and why will you use it?&lt;br&gt;
   Or Manage state&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Ans: useState Hook allows to track state in a function component. So we can say that State generally refers to data or properties that need to be tracked in an application.&lt;/p&gt;

&lt;p&gt;useState accepts an initial state and returns two values:&lt;br&gt;
const [current state, function that update the state] = useState (initial state)&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;What is prop drilling?&lt;br&gt;
   Or What is the best way to pass data 4-5 layers down?&lt;br&gt;
   Or What is a context API? How does it work?&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Ans: Prop drilling is the process in a React app where props are passed from Parent Component to Child Component&lt;/p&gt;

&lt;p&gt;Context API is a way to manage state globally. With useState it is used to share data between deeply nested component more easily than useState alone.&lt;/p&gt;

&lt;p&gt;Without Context, we will need to pass the state as "props" through each nested componen that may be not needed in that components .&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Difference between useEffect and useState?&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Or why do we need to inject dependency for useEffect?&lt;br&gt;
Ans: useEffect allows to perform side effect of component whereas useState allows to keep track state of component.&lt;/p&gt;

&lt;p&gt;If we want to stop reload or re-rendering component then we use dependency for useEffect.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;What other hooks have you used other than useState and useEffect?&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Ans: I have used useContext(), useRefs() hooks &lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Tell us about React Component lifecycle&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Ans:  There are three different phases of React component’s lifecycle:&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Mounting :&lt;/strong&gt; Mounting means putting elements into the DOM.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Updating:&lt;/strong&gt; A component is updated whenever there is a change in the component's states or props.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Unmounting:&lt;/strong&gt; This is the final phase of a component’s life cycle in which the component is destroyed and removed from the DOM.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;What is the purpose of a custom hook? How will you create a custom hook? Give us an example.&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Ans: Hooks are reusable functions. When you have component logic that needs to be used by multiple components, we can extract that logic to a custom Hook.&lt;/p&gt;

&lt;p&gt;Custom Hooks start with "use". Example: useFetch&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;What is the most challenging task you have accomplished using react?&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Ans: I have faced a challenge which is shown on UI of selected booking item details. However, I found a solution to overcome challenges. I used useParams hooks to get selected product ID and applied Find method for filtering selected product from all products.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;What is Redux and uses?&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Ans: Redux is a state management library that helps to manage state in applications.&lt;/p&gt;

&lt;p&gt;Redux is a predictable state container for JavaScript apps. As the application grows, it becomes difficult to keep it organized and maintain data flow. Redux solves this problem by managing application’s state with a single global object called Store. Redux fundamental principles help in maintaining consistency throughout application, which makes debugging and testing easier.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;What is a Higher order component? Give us an example.&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Ans: Higher order component is a function that takes a component as parameter and returns a new component.&lt;/p&gt;

&lt;p&gt;const EnhancedComponent = higherOrderComponent(WrappedComponent);&lt;br&gt;
Whereas a component transforms props into UI, a higher-order component transforms a component into another component.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;How would you optimize a react js application?&lt;br&gt;
  Or How would you prevent unnecessary component re-render in reactjs?&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Ans:  There are many ways through which one can optimize the performance of a React app,&lt;/p&gt;

&lt;p&gt;Using useMemo( ) -&lt;br&gt;
It is a React hook that is used for caching CPU-Expensive functions.&lt;/p&gt;

&lt;p&gt;useMemo( ) hook can be used to cache such functions. By using ]&lt;/p&gt;

&lt;p&gt;useMemo( ), the CPU-Expensive function gets called only when it is needed.&lt;/p&gt;

&lt;p&gt;Using React.PureComponent -&lt;br&gt;
It is a base component class that checks the state and props of a component to know whether the component should be updated.&lt;br&gt;
Instead of using the simple React.Component, we can use React.PureComponent to reduce the re-renders of a component unnecessarily.&lt;/p&gt;

&lt;p&gt;Maintaining State Colocation -&lt;br&gt;
This is a process of moving the state as close to where you need it as possible.&lt;/p&gt;

&lt;p&gt;Sometimes in React app, we have a lot of unnecessary states inside the parent component which makes the code less readable and harder to maintain. Not to forget, having many states inside a single component leads to unnecessary re-renders for the component.&lt;/p&gt;

&lt;p&gt;It is better to shift states which are less valuable to the parent component, to a separate component.&lt;/p&gt;

&lt;p&gt;Lazy Loading -&lt;br&gt;
 It is a technique used to reduce the load time of a React app. Lazy loading helps reduce the risk of web app performances to a minimum.&lt;/p&gt;

&lt;p&gt;*&lt;em&gt;What are the features of React? *&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;Ans: Most common features of React are listed below:&lt;br&gt;
React uses the virtual DOM instead of the real DOM.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;It uses server-side rendering.&lt;/li&gt;
&lt;li&gt;It follows uni-directional data flow or data binding.&lt;/li&gt;
&lt;li&gt;It uses reusable or composable UI components for developing the view&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Why can’t browsers read JSX?&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Ans:  Browsers can only read JavaScript objects but JSX is not a regular JavaScript object. Thus to enable a browser to read JSX, first, we need to transform JSX file into a JavaScript object using JSX transformers like Babel and then pass it to the browser.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;What is React Router?&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Ans: React Router is a powerful routing library built on top of React, which helps in adding new screens and flows to the application. This keeps the URL in sync with data that’s being displayed on the web page. It maintains a standardized structure and behavior and is used for developing single-page web applications. React Router has a simple API.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;What is the purpose of render() in React.&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Ans: Each React component must have a render() mandatorily. It returns a single React element which is the representation of the native DOM component. If more than one HTML element needs to be rendered, then they must be grouped together inside one enclosing tag such as &lt;/p&gt;, , etc.

&lt;p&gt;&lt;strong&gt;What is the significance of keys in React?&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Ans: Keys are used for identifying unique Virtual DOM Elements with their corresponding data driving the UI. They help React to optimize the rendering by recycling all the existing elements in the DOM. These keys must be a unique number or string, using which React just reorders the elements instead of re-rendering them. This leads to increase in application’s performance.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;What are the different ways to style a React component?&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Ans:  There are many different ways through which one can style a React component. Some of the ways are :&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Inline Styling:&lt;/strong&gt; We can directly style an element using inline style attributes. Make sure the value of style is a JavaScript object.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Using JavaScript object:&lt;/strong&gt; We can create a separate JavaScript object and set the desired style properties. This object can be used as the value of the inline style attribute.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;CSS Modules:&lt;/strong&gt; We can create a separate CSS module and import this module inside our component. Create a file with “.module.css”‘ extension.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Why is it necessary to start component names with a capital letter?&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Ans: In React, it is necessary to start component names with a capital letter. If we start the component name with lower case, it will throw an error as an unrecognized tag. It is because, in JSX, lower case tag names are considered as HTML tags.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;What are fragments?&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Ans: In React, Fragments are used for components to return multiple elements. It allows you to group a list of multiple children without adding an extra node to the DOM.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;How can you create a component in React?&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Ans:  Function Components: This is the simplest way to create a component in React. These are the pure JavaScript functions that accept props object as the first parameter and return React elements.&lt;/p&gt;

&lt;p&gt;&lt;code&gt;function Greeting({ message }) {  &lt;br&gt;
  return &amp;lt;h1&amp;gt;{&lt;/code&gt;Hello, ${message}&lt;code&gt;}&amp;lt;/h1&amp;gt;  &lt;br&gt;
}&lt;/code&gt;&lt;br&gt;&lt;br&gt;
Class Components: The class components method facilitates you to use ES6 class to define a component. The above function component can be written as:&lt;/p&gt;

&lt;p&gt;&lt;code&gt;class Greeting extends React.Component {  &lt;br&gt;
  render() {  &lt;br&gt;
    return &amp;lt;h1&amp;gt;{&lt;/code&gt;Hello, ${this.props.message}&lt;code&gt;}&amp;lt;/h1&amp;gt;  &lt;br&gt;
  }  &lt;br&gt;
}&lt;/code&gt;&lt;/p&gt;

</description>
    </item>
    <item>
      <title>ES6 Concepts</title>
      <dc:creator>S. M.  Mahmudur Rahman</dc:creator>
      <pubDate>Sat, 05 Mar 2022 10:55:37 +0000</pubDate>
      <link>https://forem.com/mahmudurbd/es6-concepts-3ghm</link>
      <guid>https://forem.com/mahmudurbd/es6-concepts-3ghm</guid>
      <description>&lt;p&gt;&lt;strong&gt;Tell me about Es6&lt;/strong&gt;&lt;br&gt;
  &lt;strong&gt;Or what ES6 features did you use?&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Ans: ES6 was released in June 2015, which was developed by Brendan Eich and that is the sixth edition of the language. Primarily, it was named ES6 which is renamed as ECMAScript 2015 later. This edition includes several new features that are Let and const keywords, spread operators,  class, arrow functions, for...of loop, modules, iterators, promises, and many more.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;What are the differences between var, let, and const?&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Ans: There few differences between var, let, const which are given below:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;Var declaration are globally scoped or functioned scoped whereas let and const are block scoped.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Var variables can be updated and redeclared whereas let and const both variables can not be redeclared. However, let variable can be updated but const variable not.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Var and let variable can be declared without being initialized whereas const variable must be initialized during declaration.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Why will you use default parameters?&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Ans: If no value or undefined is passed then we can use the default parameters to set default values for named parameters.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;How does the Spread operator work?&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Ans: The list of parameters is obtained using the spread operator. Three dots (...) are used to represent it and it divides an iterable (such as an array or a string) into individual elements. It's mostly used in JavaScript to make shallow copies of JS and to join two arrays together or to concatenate them. &lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Difference between class and object&lt;/strong&gt;&lt;br&gt;
Ans: &lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Object&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Object is an instance of a class.&lt;/li&gt;
&lt;li&gt;Object is a real world entity such as pen, laptop, mobile, bed, keyboard, mouse, chair etc.&lt;/li&gt;
&lt;li&gt;Object is a physical entity.&lt;/li&gt;
&lt;li&gt;Object is created many times as per requirement.&lt;/li&gt;
&lt;li&gt;Object allocates memory when it is created.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Class&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Class is a blueprint or template from which objects are created.&lt;/li&gt;
&lt;li&gt;Class is a group of similar objects.&lt;/li&gt;
&lt;li&gt;Class is a logical entity.&lt;/li&gt;
&lt;li&gt;Class is declared once.&lt;/li&gt;
&lt;li&gt;Class doesn't allocated memory when it is created.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;What is a Prototype chain?&lt;br&gt;
   Or how does inheritance work in JavaScript?&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Ans: Prototype is basically a property of a JavaScript function. At each time we create a function in JavaScript, JavaScript engine adds an extra property called prototype to the created function.&lt;/p&gt;

&lt;p&gt;In JavaScript, each object contains a prototype object that acquires properties and methods from it. Again an object's prototype object may contain a prototype object that also acquires properties and methods, and so on. It can be seen as prototype chaining.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Explain Call by value vs call by reference&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Ans: While calling a function, we pass values of variables to it and these functions are known as “Call By Values”.&lt;br&gt;
While calling a function, instead of passing the values of variables, we pass address of variables(location of variables) to the function, and this function is known as “Call By References”.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;What is scope in JavaScript?&lt;/strong&gt;&lt;br&gt;
&lt;strong&gt;Or Explain JavaScript scope, Block scope, and global scope?&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Ans: Scope refers to the area where an item such as a function or variable is visible and accessible to other code.&lt;/p&gt;

&lt;p&gt;When a variable is defined inside a block and it is only accessible to the code within the curly braces { } is called block scope&lt;/p&gt;

&lt;p&gt;Variables declared outside any function have Global Scope. Global variables can be accessed from anywhere in a JavaScript program.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;What is a Higher-order Function?&lt;/strong&gt;&lt;br&gt;
Ans: A higher-order function can be defined as a function that accepts one or more functions as arguments and returns a function as a result. Using higher-order functions in our code enhances the execution speed of our code and speeds up our development skills.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;What is API? Difference between Get vs post?&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Ans: API is the abbreviation of the term Application Programming Interface is used to communicate between apps and to access and fetch the required information.&lt;/p&gt;

&lt;p&gt;Difference between Get and Post are given below:&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Get&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;GET requests are often used for fetching documents and GET parameters are used to describe which document we are looking for (or)  what page we are on (or) things of that nature. &lt;/li&gt;
&lt;li&gt;GET Parameters are included in URL&lt;/li&gt;
&lt;li&gt;Get request is not secured because data is exposed in URL bar.&lt;/li&gt;
&lt;li&gt;Get request is more efficient and used more than Post.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Post&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;POST parameters are often used for updating data for actually making changes to the server (or) to the data held on the server&lt;/li&gt;
&lt;li&gt;POST parameters are included in the body&lt;/li&gt;
&lt;li&gt;Post request is secured because data is not exposed in URL bar.&lt;/li&gt;
&lt;li&gt;Post request is less efficient and used less than get.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Difference between local storage and Session storage&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Ans: Session storage is similar to local storage but the difference is that while data in local storage doesn't expire, data in session storage is cleared when the page session ends.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;What are cookies? And why will you use it?&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Ans: Cookies are files that hold information about you, your web browser and your behavior on the internet. They are tiny files stored on your PC or device, which can be used by websites or web apps to tailor your online experience.&lt;/p&gt;

&lt;p&gt;Cookies  are used to identify my computer as I use a computer network. Specific cookies known as HTTP cookies are used to identify specific users and improve your web browsing experience. &lt;/p&gt;

&lt;p&gt;Data stored in a cookie is created by the server upon internet connection. This data is labeled with an ID unique.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;What is object-oriented programming?&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Ans: The word object-oriented is the combination of two words that is object and oriented. Object-oriented programming (OOP) is a computer programming model that organizes software design around data, or objects, rather than functions and logic. An object can be defined as a data field that has unique attributes and behavior.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;How will you debug a JavaScript application?&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Ans: Debugging is not easy but fortunately, all modern browsers have a built-in JavaScript debugger. Built-in debuggers can be turned on and off, forcing errors to be reported to the user. With a debugger, I can also set breakpoints and examine variables while the code is executing otherwise have to follow the steps at the bottom of that page and activate debugging in browser with the F12 key, and select "Console" in the debugger menu.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;What is arrow function? What are the advantages of arrow function?&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Ans: Arrow functions are introduced in ES6 and the definition of the arrow function consists of parameters, followed by an arrow (=&amp;gt;) and the body of the function. An Arrow function is also called as 'fat arrow' function. We cannot use them as constructors.&lt;/p&gt;

&lt;p&gt;The advantages of the arrow function are listed below:&lt;br&gt;
It reduces code size.&lt;/p&gt;

&lt;p&gt;The return statement is optional for a single line function.&lt;br&gt;
Functional braces are optional for a single-line statement.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;What are the template literals in ES6?&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Ans: Template literals are a new feature introduced in ES6 which provides an easy way of creating multiline strings and performing string interpolation. Template literals are enclosed by the backtick (&lt;code&gt;&lt;/code&gt;) character and template literals were referred to as template strings prior to ES6.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;What is Babel?&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Ans: Babel is one of the popular and open-source transpilers of JavaScript. It is mainly used for converting the ES6 plus code into the backward-compatible version of JavaScript that can be run by previous JavaScript engines.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Define about set.&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Ans: A set is a data structure that allows us to create a collection of unique values. It is a collection of values that are similar to arrays and it does not include any duplicates. It is used to support both object references and primitive values.&lt;/p&gt;

&lt;p&gt;&lt;code&gt;Example&lt;br&gt;
let colors = new Set(['Green', 'Red', 'Orange', 'Yellow', 'Red']);    &lt;br&gt;
console.log(colors);    &lt;br&gt;
Output: set{'Green', 'Red', 'Orange', 'Yellow', 'Red'}&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;What is the purpose of using destructuring?&lt;/strong&gt;&lt;br&gt;
Ans: Destructuring was introduced in ES6 as a way to extract data from arrays and objects into a separate variable. It is used to extract smaller fragments from objects and arrays.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;What are the new String methods introduced in ES6?&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Ans: Four string methods introduced in ES6 that are listed below:&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;string.startsWith() :&lt;/strong&gt; It determines if a string begins with the characters of a given string.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;string.endsWith() :&lt;/strong&gt;  It determines if a string ends with the characters of a given string.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;string.includes() :&lt;/strong&gt; It will return true if the given argument is present in the string.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;string.repeat() :&lt;/strong&gt; It creates and returns a new string which contains the given number of copies of the string on which this method was called, concatenated together.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Explain difference between for…of and for…in.&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Ans: It is similar to for loop that iterates through the properties of an object. It is useful when we require to visit the properties or keys of the object.&lt;/p&gt;

&lt;p&gt;However, for-of loop which allows us to iterate over arrays very easily and the code inside the loop is executed for each element of the iterable array.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;What is Bubbling and Capturing?&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Ans: The event bubbles up or goes to its parent, grandparents, and grandparent's parent until it reaches the window in the Bubbling Phase and the event starts out from window down to the element that prompted the event or the event target in the Capturing Phase.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;What is the difference between const and Object.freeze()?&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Ans: Const creates an immutable binding, which means you can't change its value whereas  Object.freeze() method freezes an object that prevents new properties from being added to it and this method prevents the modification of existing property, attributes, and values.&lt;/p&gt;

</description>
    </item>
    <item>
      <title>Basic JS Concepts</title>
      <dc:creator>S. M.  Mahmudur Rahman</dc:creator>
      <pubDate>Sat, 05 Mar 2022 09:32:23 +0000</pubDate>
      <link>https://forem.com/mahmudurbd/basic-js-concepts-n8i</link>
      <guid>https://forem.com/mahmudurbd/basic-js-concepts-n8i</guid>
      <description>&lt;p&gt;&lt;strong&gt;How does JavaScript work? &lt;br&gt;
  or What is the JavaScript Event Loop?&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Ans: In JavaScript, the event loop is a process that waits for the Call Stack to be clear before pushing callbacks from the Task Queue to the Call Stack. Once the Stack is clear, the event loop triggers and checks the Task Queue for available callbacks and If there are any, it pushes it to the Call Stack, waits for the Call Stack to be clear again, and repeats the same process&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Or Though JavaScript is single-threaded, how does it handle concurrent work?&lt;/strong&gt; &lt;br&gt;
  &lt;strong&gt;Or Is JavaScript Single-threaded or multi-threaded?&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Ans: JavaScript is a single-threaded language. Because the language specification does not allow the programmer to write code so that the interpreter can run parts of it in parallel in multiple threads or processes.&lt;br&gt;
  Or Is JavaScript Synchronous or asynchronous?&lt;br&gt;
Ans: JavaScript is a client-side and server-side scripting language inserted into HTML pages and is understood by web browsers. JavaScript is also an Object-based Programming language.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;How does JavaScript code is executed in Browser?&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Ans: Mostly every web browsers nowadays have their own JavaScript engines. So, it is the JavaScript engine that understands the code and runs it.&lt;/p&gt;

&lt;p&gt;In this case, we have used a chrome browser to run our program that has the "V8" JavaScript engine, which is also used for creating the Node.js. As we already know, JavaScript is an interpreted language that means it gets executed in line by line manner or which means the JavaScript engine converts the Js code line by line and runs in the same manner instead of converting the whole program once.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;What are the differences between “==” and “===” ?&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Ans: Both are comparison operators and “==” is used to compare only values whereas “===” is used to compare both values and types.&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;&lt;strong&gt;What is a callback function?&lt;/strong&gt;&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Ans: In JavaScript the definition of  callback is a plain JavaScript function passed to some method as an argument or option. It is a function that is to be executed after another function has finished executing, hence the name ‘call back‘.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;When will you return something from a function?&lt;/strong&gt; &lt;br&gt;
   &lt;strong&gt;Or How will you return more than one value from a function?&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Ans: The return statement is used to return a particular value from the function to the function caller. So we can say that the function will stop executing when the return statement is called and the return statement should be the last statement in a function because the code after the return statement will be unreachable.&lt;/p&gt;

&lt;p&gt;We can return primitive values (such as Boolean, number, string, etc.) and Object types (such as functions, objects, arrays, etc.) by using the return statement.&lt;/p&gt;

&lt;p&gt;We can also return multiple values using the return statement. It cannot be done directly so that we have to use an Array or Object to return multiple values from a function.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Tell me about bind, call and apply.&lt;br&gt;
   Or How many arguments does call apply bind take?&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Ans: &lt;br&gt;
Call method invokes the function and allows you to pass in arguments one by one and Apply method invokes the function and allows you to pass in arguments as an array whereas Bind method returns a new function, allowing you to pass in a this array and any number of arguments.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;What is a Closure in JavaScript? How does it work?&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Ans: A closure can be defined as a JavaScript feature in which the inner function has access to the outer function variable. The closure has three scope chains listed as follows:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Access to its own scope.&lt;/li&gt;
&lt;li&gt;Access to the variables of the outer function.&lt;/li&gt;
&lt;li&gt;Access to the global variables.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;It gives you access to an outer function’s scope from an inner function. In JavaScript, closures are created every time a function is created. To use a closure, simply define a function inside another function and expose it.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;What does the “this” keyword indicate in JavaScript?&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Ans: In JavaScript this keyword refers to the object it belongs to. It has different values depending on where it is used. In a method, this refers to the owner object and in a function, this refers to the global object.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;What is Event bubbling in js?&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Ans: Event bubble is a type of event propagation where the event is first triggered on the most bottom target element and then continuously triggered on the ancestor of the target element in the same nesting hierarchy until it reaches the external DOM element or document object.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Or How does event delegate work in JS?&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Ans: Event delegate works such a way if we have a lot of elements handled in a similar way, then instead of assigning a handler to each of them – we put a single handler on their common ancestor.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Explain hoisting in JavaScript.&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Ans: Housing is the default behavior of javascript. Here declaration of functions and variables are moved on top of the scope.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;What is a recursive function function?&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Ans: Recursion is a process of calling itself until it arrives at a result. So we can say that, when a function that calls itself is called a recursive function and recursive function must have a condition to stop calling itself. If we do not stop it, the function is called indefinitely.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Difference between undefined and null.&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Ans: Null is an object that means it is an assignment value whereas undefined is a type that means a variable is declared, but no value has been assigned a value.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;NULL example,&lt;/strong&gt;&lt;br&gt;
&lt;code&gt;var demo = null;&lt;br&gt;
alert(demo); //shows null&lt;br&gt;
alert(typeof demo); //shows object&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Undefined example,&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;code&gt;var demo;&lt;br&gt;
alert(demo); //shows undefined&lt;br&gt;
alert(typeof demo); //shows undefined&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;What are the different data types in JavaScript?&lt;/strong&gt;&lt;br&gt;
Ans: JavaScript has 7 types of data types. These are:&lt;br&gt;
Number&lt;br&gt;
String&lt;br&gt;
Boolean&lt;br&gt;
Undefined&lt;br&gt;
Null&lt;br&gt;
Object&lt;br&gt;
Symbol(From ES6)&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Or Primitive data type and non-primitive data type&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Ans: Primitives are known as being immutable data types because there is no way to change a primitive value once it gets created. Primitives are compared by value.&lt;/p&gt;

&lt;p&gt;Non-primitive values are mutable data types. The value of an object can be changed after it gets created. Objects are not compared by value.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;What is DOM?&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Ans: JavaScript can access all the elements in a web page using the Document Object Model (DOM). The web browser creates a DOM of the webpage when the page is loaded.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Is JavaScript a static type or a dynamic type?&lt;/strong&gt;&lt;br&gt;
     &lt;strong&gt;Or How will you know the type of a JavaScript variable?&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Ans: JavaScript is a dynamically typed language. In a dynamically typed language, the type of a variable is checked during run-time in contrast to statically typed language, where the type of a variable is checked during compile-time.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;What are the scopes of a variable in JavaScript?&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Ans: The scope of a variable means it is the region of a program in which it is defined. JavaScript variable will have only two scopes.&lt;/p&gt;

&lt;p&gt;• &lt;strong&gt;Global Variables&lt;/strong&gt; − A global variable which has global scope and it is visible everywhere in your JavaScript code.&lt;/p&gt;

&lt;p&gt;• &lt;strong&gt;Local Variables&lt;/strong&gt; − A local variable will be visible only within a function where it is defined. Function parameters are always local to that function.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;What are the variable naming conventions in JavaScript?&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;For naming variables in JavaScript following rules are to be followed:&lt;/p&gt;

&lt;p&gt;Should not use any of the JavaScript reserved keyword as variable name. For example, break or boolean variable names are not valid.&lt;br&gt;
Should not start with a numeral (0-9) for making JavaScript variable names. They must begin with a letter or the underscore character. For example, 123name is an invalid variable name but _123name or name123 is a valid one.&lt;/p&gt;

&lt;p&gt;JavaScript variable names are case sensitive. For example, Test and test are two different variables.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;In how many ways can you create an array in JS?&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;There are three different ways of creating an array in JavaScript, namely:&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;By creating instance of an array:&lt;/strong&gt;&lt;br&gt;
var someArray = new Array();&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;By using an array constructor:&lt;/strong&gt;&lt;br&gt;
var someArray = new Array(‘value1’, ‘value2’,…, ‘valueN’);&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;By using an array literal:&lt;/strong&gt;&lt;br&gt;
var someArray = [value1, value2,…., valueN];&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;What are global variables? How are these variables declared?&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Ans: Global variables are declared outside of a function for accessibility throughout the program, while local variables are stored within a function using var for use only within that function’s scope. If you declare a variable without using var, even if it’s inside a function, it will still be seen as global.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;What is the use of the Push method in JavaScript?&lt;/strong&gt;&lt;br&gt;
Ans: The push method is used to add or append one or more elements to an Array end. Using this method, we can append multiple elements by passing multiple arguments.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;How are event handlers utilized in JavaScript?&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Ans: Events are the actions that result from activities, such as clicking a link or filling a form by the user. An event handler is required to manage the proper execution of all these events. Event handlers are an extra attribute of the object. This attribute includes the event’s name and the action taken if the event takes place.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;What is the unshift method in JavaScript?&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Ans: The method of unshift is like the push method, which works at the beginning of the array and this method is used to prepend one or more elements to the beginning of the array.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;What is Implicit Type Coercion in javascript?&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Ans: Implicit type coercion in javascript is automatic conversion of value from one data type to another. It takes place when the operands of an expression are of different data types.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;What is NaN property in JavaScript?&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Ans: In JavaScript, NaN property means Not a Number and It represents a value that is not a valid number. It can be used to check whether a number entered is a valid number or not a number.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;What is the typeof operator?&lt;/strong&gt;&lt;br&gt;
Ans: JavaScript typeof operator is used to find the type of a JavaScript variable. It returns the type of a variable or an expression.&lt;/p&gt;

&lt;p&gt;-------------------&lt;strong&gt;Notes for Hoisting&lt;/strong&gt;-------------------------&lt;/p&gt;

&lt;p&gt;*&lt;em&gt;**Note - Variable initializations are not hoisted, only variable declarations are hoisted&lt;/em&gt;*&lt;/p&gt;

&lt;p&gt;*&lt;em&gt;**Note - To avoid hoisting, you can run javascript in strict mode by using “use strict” on top of the code&lt;/em&gt;*&lt;/p&gt;

</description>
      <category>javascript</category>
      <category>programming</category>
    </item>
    <item>
      <title>CSS Common Concepts</title>
      <dc:creator>S. M.  Mahmudur Rahman</dc:creator>
      <pubDate>Sat, 05 Mar 2022 06:00:37 +0000</pubDate>
      <link>https://forem.com/mahmudurbd/css-common-concepts-40hc</link>
      <guid>https://forem.com/mahmudurbd/css-common-concepts-40hc</guid>
      <description>&lt;p&gt;&lt;strong&gt;What is Flex layout? Difference Flex and grid layout?&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Ans: Flex layout is a one-dimensional layout method for arranging items in rows or columns.&lt;br&gt;
Flexbox is designed for one-dimensional layout whereas grid is 2 dimensional layout. Flexbox is designed for small scale layout while grid is for large scale layout. &lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Explain CSS position property? What are some differences between absolute position and relative position?&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Ans: CSS position property defines the position of an element in document. It works with top, bottom, left , right and Z-index to determine the final position of an element on a page. There are five different properties value which are static, relative, absolute, sticky, fixed.&lt;/p&gt;

&lt;p&gt;Relative position places an element relative to it’s current position without changing the layout around it whereas Abosolute position places an element relative to its parent’s position with changing the layout around it.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;What is a box model? And what are the different elements of a box model?&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Ans: Around every HTML element a rectangle box is wrapped. The box model consists of width and height of rectangle box and is used to determine width and height of the rectangle box.&lt;br&gt;
There are main four elements in a box model which are content, padding, border, margin&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;What is a Hover effect? What is the purpose of the active class?&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Ans: CSS hover effect takes place when an user hover over the element  and the element responds with transition effects. It is used to mark an element on web page and it is an effective way to improving user experience. &lt;/p&gt;

&lt;p&gt;The use of &lt;code&gt;:active&lt;/code&gt; pseudo-class to select an element which is activated when the user clicks on it.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;What are the different types of Selectors in CSS?&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Ans: There are different types of Selectors in CSS which are listed below.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Universal Selector:&lt;/strong&gt; The provided style will be applied to all elements by selecting all elements on a page&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Element type Selector:&lt;/strong&gt; The element selector selects HTML elements based on the element name.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;ID Selector:&lt;/strong&gt; The id selector uses the id attribute of an HTML element to select a specific element.&lt;/p&gt;

&lt;p&gt;Class Selector: The class selector selects HTML elements with a specific class attribute.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Grouping Selector:&lt;/strong&gt; The grouping selector selects all the HTML elements with the same style definitions.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;What is CSS Specificity?&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Ans: It is a process of determining which CSS rule will be applied to an element.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;What is a CSS Preprocessor? What are some benefits of Sass?&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Ans: A CSS preprocessor is a scripting language that extends CSS and is compiled into regular CSS syntax.&lt;/p&gt;

&lt;p&gt;There are some benefits of Sass which are given below.&lt;br&gt;
To write clean, easy and less CSS in a programming construct&lt;br&gt;
Contain fewer codes and help to write CSS quicker&lt;br&gt;
Compatible with all version of CSS so that any available CSS libraries can be used.&lt;/p&gt;

&lt;p&gt;More stable, powerful, and elegant because it is an extension of CSS. So, it is easy for designers and developers to work more efficiently and quickly.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;What is a Pseudo element? What is pseudo-class?&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Ans: Pseudo Element: Task of Pseudo element create items that do not normally exist in the document tree. For example ::after, ::before, ::first-letter, ::first-line, ::selection&lt;/p&gt;

&lt;p&gt;Pseudo Class: Pseudo class help us to select regular items under certain conditions. For example :hover, :focus, :link, :active, :visited&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;How will you use media queries to make a website responsive?&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Ans: There are many ways of media queries to make website responsive which are&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Using min-width and max-width media queries&lt;/li&gt;
&lt;li&gt;Multiple media queries for one call&lt;/li&gt;
&lt;li&gt;Media queries for landscape layout&lt;/li&gt;
&lt;li&gt;Media queries for portrait layout&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;How will you make font size responsive?&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Ans: Two best way to make font size responsive which is listed below:&lt;br&gt;
By using &lt;code&gt;vw&lt;/code&gt;unit for font size as a result font size will follow the size of  browser window&lt;/p&gt;

&lt;p&gt;Using media queries font size can be changed so that font size can vary on specific devices.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;What are the difference between reset CSS and normalze CSS?&lt;/strong&gt;&lt;br&gt;
Ans: Normalize CSS means to make built-in browser styling whereas Reset CSS means to remove built-in browser styling&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;How is the different border-box from content-box?&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Ans:  In content-box, there is height and the width properties consist only of the content by excluding the border and padding whereas border-box property includes the content, padding and border in the height and width properties&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Why should we use floating property in CSS?&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Ans: For positioning HTML elements horizontally either towards the left or right of the container.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;What are the different ways to hide elements using CSS?&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Ans: By using display:none, visibility:hidden,  position:absolute&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;What is cascading in CSS?&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Ans: Cascading is a  process of  style declarations and defining weight or importance to the styling rules that help the browser to select what rules have to be applied in times of conflict.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;What is differences between nth-child() and nth-of-type?&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Ans:  The purpose of nth-child() pseudo-class is to match elements based on the number that represents the position of an element based on the siblings. The number is used to match an element on the basis of the element’s position amongst its siblings.&lt;/p&gt;

&lt;p&gt;However, The nth-of-type() pseudo-class helps in matching the selector based on a number that represents the position of the element within the elements that are the siblings of its same type. The number can also be given as a function or give keywords like odd or even.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;What does ! important means in CSS?&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Ans: Important will have the highest precedence and it overrides cascading property.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;What is the importance of CSS sprites?&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Ans: CSS sprites is used for combining multiple images in a single larger image. Actually, it helps to represent icons that are used in the user interfaces. It reduces the number of HTTP requests to get data of multiple images.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;How does Z-index function?&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Ans: While using CSS for positioning HTML elements, overlapping may occur. Z-index helps in specifying the overlapping element. The number of Z-index can be negative or positive and the default value is zero.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;What is the difference between padding and margin?&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Ans: Padding creates space around the content of elements whereas margin creates space around elements. So we can say that margin generates space outer side of content of element but padding generates space inner side of content&lt;/p&gt;

</description>
    </item>
  </channel>
</rss>
