<?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: Sonu Jha</title>
    <description>The latest articles on Forem by Sonu Jha (@skj4ua).</description>
    <link>https://forem.com/skj4ua</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%2F580142%2F419c02e5-5682-457d-94cf-c941bca0a7cd.png</url>
      <title>Forem: Sonu Jha</title>
      <link>https://forem.com/skj4ua</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://forem.com/feed/skj4ua"/>
    <language>en</language>
    <item>
      <title>React Interview Questions - Junior Level</title>
      <dc:creator>Sonu Jha</dc:creator>
      <pubDate>Fri, 25 Jun 2021 12:52:29 +0000</pubDate>
      <link>https://forem.com/skj4ua/react-interview-questions-junior-level-45g</link>
      <guid>https://forem.com/skj4ua/react-interview-questions-junior-level-45g</guid>
      <description>&lt;p&gt;Lets Begin,&lt;/p&gt;

&lt;p&gt;1&amp;gt; What are refs used for ?&lt;/p&gt;

&lt;p&gt;Ans. Refs allow you to get direct access to a DOM element or an instance of a Component.&lt;/p&gt;

&lt;p&gt;2&amp;gt; What happens when you call setState ?&lt;/p&gt;

&lt;p&gt;Ans. The first thing React will do when setState is merge with object you passed into setState into the current state of the component. This will kick of a process called reconciliation. &lt;br&gt;
The most efficient way possible, update the UI based on this new state.&lt;/p&gt;

&lt;p&gt;3&amp;gt; When rendering a list what is a key and what is its purpose ?&lt;/p&gt;

&lt;p&gt;Ans. Key helps React identify which items have changed, are added or are removed. &lt;br&gt;
Keys should be given to the elements inside the array to give the elements a stable identity.&lt;/p&gt;

&lt;p&gt;4&amp;gt; What happens during the lifecycle of a React component ?&lt;/p&gt;

&lt;p&gt;Ans. At the highest level, React components have lifecycle events that fall into three general categories.&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Initialization&lt;/li&gt;
&lt;li&gt;State/Property Updates&lt;/li&gt;
&lt;li&gt;Destruction&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Initialization :&lt;br&gt;
getInitialState()&lt;br&gt;
getDefaultProps()&lt;/p&gt;

&lt;p&gt;ComponentWillMount()&lt;br&gt;
render()&lt;br&gt;
componentDidMount()&lt;/p&gt;

&lt;p&gt;Update:&lt;br&gt;
componentWillReceiveProps()&lt;br&gt;
shouldComponentUpdate()&lt;/p&gt;

&lt;p&gt;componentWillUpdate()&lt;br&gt;
render()&lt;br&gt;
componentDidUpdate()&lt;/p&gt;

&lt;p&gt;Destruction:&lt;br&gt;
componentWillUnmount()&lt;/p&gt;

&lt;p&gt;5&amp;gt; How do you prevent the default behavior in an event callback in React ?&lt;/p&gt;

&lt;p&gt;Ans. You call e.preventDefault(); on the event e passed into the callback.&lt;/p&gt;

&lt;p&gt;6&amp;gt; What does it mean for a component to be mounted in React ?&lt;/p&gt;

&lt;p&gt;Ans.  It has a corresponding element created in the DOM and is connected to that.&lt;/p&gt;

&lt;p&gt;7&amp;gt; How do you prevent a component from Rendering in Reacr ?&lt;/p&gt;

&lt;p&gt;Ans. Return null from the render method.&lt;/p&gt;

&lt;p&gt;8&amp;gt;  What's the difference between a controlled component and an Uncontrolled one in React ?&lt;/p&gt;

&lt;p&gt;Ans. This relates to stateful DOM components(form elements) and the React docs explain the difference:&lt;/p&gt;

&lt;p&gt;A Controlled component is one the takes its current value through props and notifies the changes through callback like onChange. A parent component "controls" it by handling the callback and managing its own state and passing the new values as props to the controlled component. you can call this as a "dumb component".&lt;/p&gt;

&lt;p&gt;A Uncontrolled Component is one that stores its own state internally, and you query the DOM using a ref to find its current value when you need it. This is a bit more like traditional HTML.&lt;/p&gt;

&lt;p&gt;9&amp;gt; What is Flux ?&lt;/p&gt;

&lt;p&gt;Ans. Unidirectional application flow paradigm/idea.&lt;/p&gt;

&lt;p&gt;10&amp;gt; What is Reconciliation ?&lt;/p&gt;

&lt;p&gt;Ans. Reconciliation is the process of comparing the DOM Tree before and after element changes and updating them accordingly.&lt;/p&gt;

</description>
      <category>react</category>
    </item>
    <item>
      <title>React Interview Questions - Basic</title>
      <dc:creator>Sonu Jha</dc:creator>
      <pubDate>Fri, 18 Jun 2021 16:19:42 +0000</pubDate>
      <link>https://forem.com/skj4ua/react-interview-questions-basic-1ja1</link>
      <guid>https://forem.com/skj4ua/react-interview-questions-basic-1ja1</guid>
      <description>&lt;p&gt;Lets Begin with some of the basic ReactJs Interview Questions&lt;/p&gt;

&lt;p&gt;1&amp;gt; How does React Work ?&lt;/p&gt;

&lt;p&gt;Ans. React creates a virtual DOM. when there is any state changes in the DOM a diffing Algorithm runs to check what has changed in the in the virtual DOM. Next Reconciliation takes place where the where it udpates the DOM with the Difference.&lt;/p&gt;

&lt;p&gt;2&amp;gt; What is Context ?&lt;/p&gt;

&lt;p&gt;Ans. Context provides a way to pass data through the component tree without having to pass props down manually at the every level.&lt;/p&gt;

&lt;p&gt;3&amp;gt; what is props in react ?&lt;/p&gt;

&lt;p&gt;Ans. Props accept values in the component that are passed down to a child component.&lt;/p&gt;

&lt;p&gt;primary purpose of props in react is to provide following component functionality :&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;pass custom data to your react component&lt;/li&gt;
&lt;li&gt;Trigger state changes&lt;/li&gt;
&lt;li&gt;use via this.props.reactProp inside Component's render() method.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;4&amp;gt; what is the use of refs ?&lt;/p&gt;

&lt;p&gt;Ans. Refs provide a way to access DOM nodes or React elements created in the render method. &lt;br&gt;
They should be avoided in most cases, however, they can be useful when we need direct access to DOM element or an instance of a component.&lt;/p&gt;

&lt;p&gt;Refs are created using React.createRef() and attached to React elements via the ref attribute.&lt;/p&gt;

&lt;p&gt;Ex. class MyComponent extends React.Component {&lt;br&gt;
  constructor(props) {&lt;br&gt;
    super(props);&lt;br&gt;
    this.myRef = React.createRef();  }&lt;br&gt;
  render() {&lt;br&gt;
    return &lt;/p&gt;;  }&lt;br&gt;
}

&lt;p&gt;5&amp;gt; what is JEST ?&lt;/p&gt;

&lt;p&gt;Ans. Jest is a javascript unit testing framework made by facebook based on jasmine and provides automated mock creation and a jsdom environment. It's often used for testing React Components.&lt;/p&gt;

&lt;p&gt;6&amp;gt; what are the advantages of ReactJs ?&lt;/p&gt;

&lt;p&gt;Ans. 1&amp;gt; Increases the applications performanec with Virtual Dom&lt;br&gt;
     2&amp;gt; JSX makes code easy to read and write&lt;br&gt;
     3&amp;gt; it renders both on client and server side&lt;br&gt;
     4&amp;gt; Easy to integrate with other frameworks&lt;br&gt;
     5&amp;gt; Easy to write UI test case and integration with tools   such as JEST.&lt;/p&gt;

&lt;p&gt;7&amp;gt; How would you write an inline style in React ?&lt;/p&gt;

&lt;p&gt;Ans. &lt;/p&gt;

&lt;p&gt;8&amp;gt; What is React ?&lt;/p&gt;

&lt;p&gt;Ans. React is an open source Javascript library created by facebook for building complex, interactive UIs in web and mobile applications. React's core purpose is to build UI components; It is often referred to as just the "V" (view) in&lt;br&gt;
an "MVC" architecture.&lt;/p&gt;

&lt;p&gt;9&amp;gt; What are major features of ReactJs ?&lt;/p&gt;

&lt;p&gt;Ans. The major features of ReactJs are follows,&lt;/p&gt;

&lt;p&gt;. It uses VirtualDOM instead RealDOM considering that RealDOM manipulation are expensive.&lt;br&gt;
. Support server-side rendering.&lt;br&gt;
. Follows Unidirectional data flow or data binding.&lt;br&gt;
. Uses reuseable/composable UI components to develop the view&lt;/p&gt;

&lt;p&gt;10&amp;gt; Where in a React component should you make an AJAX request ?&lt;/p&gt;

&lt;p&gt;Ans. componentDidMount is where an AJAX request should be made in a React component.&lt;/p&gt;

&lt;p&gt;This method will be executed when the component "mounts" (is added to the DOM) for the first time.&lt;/p&gt;

&lt;p&gt;11&amp;gt; what is the difference between state and props?&lt;/p&gt;

&lt;p&gt;Ans. The state is a data structure that starts with a default value when a Component mounts. It may be mutated across time, mostly as a result of user events.&lt;/p&gt;

&lt;p&gt;Props (short for properties) are a component's configuration. They are received from above and immutable as far as the component receiving them is concerned. &lt;/p&gt;

&lt;p&gt;12&amp;gt; What is the difference between a presentational component and a container component ?&lt;/p&gt;

&lt;p&gt;Ans. Presentational components are concerned with how things look.&lt;br&gt;
     Container components are more concerned with how things work.&lt;/p&gt;

&lt;p&gt;Thanks For Reading :)&lt;/p&gt;

</description>
      <category>react</category>
    </item>
    <item>
      <title>Javascript Interview Questions - Entry Level</title>
      <dc:creator>Sonu Jha</dc:creator>
      <pubDate>Thu, 17 Jun 2021 11:55:09 +0000</pubDate>
      <link>https://forem.com/skj4ua/javascript-interview-questions-entry-level-33np</link>
      <guid>https://forem.com/skj4ua/javascript-interview-questions-entry-level-33np</guid>
      <description>&lt;p&gt;Everyday i will be sharing few Javascript Interview Questions to help you understand the languauge even better.&lt;/p&gt;

&lt;p&gt;So lets get started with basic questions that are asked in the interview.&lt;/p&gt;

&lt;p&gt;1&amp;gt; what is typeOf operator ?&lt;br&gt;
Ans.  typeOf operator examines the value and tells you what type the value is.&lt;/p&gt;

&lt;p&gt;Ex: var a =14;&lt;br&gt;
typeof(a); //returns Number.&lt;/p&gt;

&lt;p&gt;2&amp;gt; What is object type ?&lt;/p&gt;

&lt;p&gt;Ans. An object type is nothing but a collection of properties with name and value pair.&lt;/p&gt;

&lt;p&gt;Ex: var obj = {&lt;br&gt;
        a : "Hello",&lt;br&gt;
        b : 45&lt;br&gt;
}&lt;br&gt;
obj.a //"Hello" accessed with doted notation&lt;br&gt;
obj.b //45&lt;/p&gt;

&lt;p&gt;obj["a"]  //"Hello "accessed with bracket notation&lt;br&gt;
obj["b"]  //45&lt;/p&gt;

&lt;p&gt;Bracket notation is also helpful if you want to access a property/key but the name is stored in an another variable, such as:&lt;/p&gt;

&lt;p&gt;obj b= "a"&lt;/p&gt;

&lt;p&gt;obj[b]   //"Hello"&lt;br&gt;
obj["b"] //45&lt;/p&gt;

&lt;p&gt;3&amp;gt; Explain array in javascript.&lt;/p&gt;

&lt;p&gt;Ans. An array is an object that holds value(of any type) not particularly in named properties/key, but rather in numerically indexed positions. &lt;/p&gt;

&lt;p&gt;var arr = ["hello", 1 , true]&lt;br&gt;
arr[0] // "hello&lt;br&gt;
arr[1] // 1&lt;br&gt;
arr[2] // true&lt;/p&gt;

&lt;p&gt;typeof(arr) // "object"&lt;/p&gt;

&lt;p&gt;4&amp;gt; what is scope in javascript ?&lt;/p&gt;

&lt;p&gt;Ans. Each Function gets its own scope. So Scope is basically a collection of variables as well as the rules for how those variables are accessed by names.&lt;br&gt;
only code inside that function can access the function's scoped variable.&lt;/p&gt;

&lt;p&gt;5&amp;gt; Explain equality in javascript.&lt;br&gt;
Ans. Javascript have both strict and type-converting comparions:&lt;/p&gt;

&lt;p&gt;strict comparison (eg === checks for value equality without coercion)&lt;br&gt;
Abstract comparison (eg == checks for value with coercion allowed)&lt;/p&gt;

&lt;p&gt;Ex:&lt;br&gt;
var a = "42"&lt;br&gt;
var b = 42&lt;/p&gt;

&lt;p&gt;a === b // false&lt;br&gt;
a == b  // true&lt;/p&gt;

&lt;p&gt;6&amp;gt; what is let keyword in javascript ?&lt;/p&gt;

&lt;p&gt;Ans. Es6 lets you declare variable within the individual blocks (pairs of {...}) using the let keyword.&lt;/p&gt;

&lt;p&gt;let will not let you declare same variable within the same scope whereas var will simply replace it.&lt;/p&gt;

&lt;p&gt;Self Study : Try to understand temporal dead zone, Hoisting &lt;/p&gt;

&lt;p&gt;7&amp;gt; Explain null and undefined.&lt;/p&gt;

&lt;p&gt;Ans. null means that it is Currently unavilable.&lt;br&gt;
     undefined means it hasnt been initialized.&lt;/p&gt;

&lt;p&gt;8&amp;gt; What is Strict Mode ?&lt;/p&gt;

&lt;p&gt;Ans. Strict Mode is a new Feature in ECS5 that allows you to place a program or a function in a "Strict" operating context. Strict context prevents from certain action to be taken and throws more exceptions.&lt;/p&gt;

&lt;p&gt;Ex. function(){&lt;br&gt;
    "use Strict"&lt;br&gt;
}&lt;/p&gt;

&lt;p&gt;9&amp;gt; what is a polyfill ?&lt;/p&gt;

&lt;p&gt;Ans. Polyfil is  a piece of code or a plugin that allows the functionality that works on modern browser to also work on older browsers.&lt;/p&gt;

&lt;p&gt;10&amp;gt; Explain event bubbling and how one may prevent it.&lt;/p&gt;

&lt;p&gt;Ans. Event Bubbling is the concept in which an event triggers at the deepest possible element and trigers on parent elements in nesting order. &lt;/p&gt;

&lt;p&gt;one way to handle event bubbling is event.stopPropgation()&lt;/p&gt;

&lt;p&gt;11&amp;gt; what does "use strict" do ?&lt;/p&gt;

&lt;p&gt;Ans "use strict" is written at a top of a function or a program that helps you write a safer code and throws error if a global variable is created by mistake.&lt;/p&gt;

</description>
      <category>javascript</category>
    </item>
    <item>
      <title>Understanding Node Modules</title>
      <dc:creator>Sonu Jha</dc:creator>
      <pubDate>Tue, 13 Apr 2021 17:43:37 +0000</pubDate>
      <link>https://forem.com/skj4ua/understanding-node-modules-5app</link>
      <guid>https://forem.com/skj4ua/understanding-node-modules-5app</guid>
      <description>&lt;p&gt;Starting a Node application&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;create a folder - node-examples&lt;/li&gt;
&lt;li&gt;now intiliaze the package.json by typing - npm init&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Accept the standard defaults suggested and the update the package.json&lt;br&gt;
file until you end up with the file containing the following&lt;br&gt;
{&lt;br&gt;
"name": "node-examples",&lt;br&gt;
"version": "1.0.0",&lt;br&gt;
"description": "Simple Node Examples",&lt;br&gt;
"main": "index.js",&lt;br&gt;
"scripts": {&lt;br&gt;
"test": "echo \"Error: no test specified\" &amp;amp;&amp;amp; exit 1",&lt;br&gt;
"start": "node index"&lt;br&gt;
},&lt;br&gt;
"author": "Sonu Jha",&lt;br&gt;
"license": "ISC"&lt;br&gt;
}&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;now create a file name index.js &lt;/p&gt;&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;var rect = {&lt;br&gt;
    perimeter : (x,y) =&amp;gt;(2*(x+y)),&lt;br&gt;
    area: (x,y) =&amp;gt; (x*y)&lt;br&gt;
};&lt;/p&gt;

&lt;p&gt;function solveRect(l,b) {&lt;br&gt;
    console.log("Solving for rectangle with l = " + l + " and b = " + b);&lt;br&gt;
    if (l &amp;lt;= 0 || b &amp;lt;= 0) {&lt;br&gt;
        console.log("Rectangle dimensions should be greater than zero:  l = "&lt;br&gt;
               + l + ",  and b = " + b);&lt;br&gt;
    }&lt;br&gt;
    else {&lt;br&gt;
        console.log("The area of the rectangle is " + rect.area(l,b));&lt;br&gt;
        console.log("The perimeter of the rectangle is " + rect.perimeter(l,b));&lt;br&gt;
    }&lt;br&gt;
}&lt;br&gt;
solveRect(2,4);&lt;br&gt;
solveRect(3,5);&lt;br&gt;
solveRect(0,5);&lt;br&gt;
solveRect(-3,5);&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;To run the Node Application type the following at prompt
npm start&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;A simple Node Module&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Now create a file name rectangle.js and the following code to it:&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;exports.perimeter =  (x, y) =&amp;gt; (2*(x+y));&lt;/p&gt;

&lt;p&gt;exports.area = (x, y) =&amp;gt; (x*y);&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Then Update index.js as follows :&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;var rect = require('./rectangle');&lt;/p&gt;

&lt;p&gt;In Conclusion, A Node Modules are js files that are imported using require() function to use the functionalty.&lt;/p&gt;

</description>
      <category>npm</category>
      <category>node</category>
      <category>backend</category>
    </item>
  </channel>
</rss>
