<?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: Rahul Saha</title>
    <description>The latest articles on DEV Community by Rahul Saha (@rahulsaha28).</description>
    <link>https://dev.to/rahulsaha28</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%2F625757%2F79a68f49-c9a1-4338-b682-8ef92ce13b9c.jpeg</url>
      <title>DEV Community: Rahul Saha</title>
      <link>https://dev.to/rahulsaha28</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/rahulsaha28"/>
    <language>en</language>
    <item>
      <title>Interview Question</title>
      <dc:creator>Rahul Saha</dc:creator>
      <pubDate>Sat, 08 May 2021 15:20:26 +0000</pubDate>
      <link>https://dev.to/rahulsaha28/interview-question-1773</link>
      <guid>https://dev.to/rahulsaha28/interview-question-1773</guid>
      <description>&lt;p&gt;&lt;strong&gt;Q1: What is means by truthy and falsy value?&lt;/strong&gt;&lt;br&gt;
Ans: In javascript, a truthy value is a value that considers true when encountered in a Boolean context. We consider the value that passes in the if block. Truthy value is &lt;code&gt;true, {}, [], 42, "0", "false", new Date()&lt;/code&gt;, and falsy value is &lt;code&gt;false, 0, "", null, undefined, NaN&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Q2: What is the difference between null and undefined?&lt;/strong&gt;&lt;br&gt;
Ans: Undefined variable is those that variable is declared in the program but have not been given any value. But the null value is used to represent the no value or no object. It implies that no object, null string, no valid boolean value, no number, no array object.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Q3: How you get undefined?&lt;/strong&gt;&lt;br&gt;
Ans: I think I get undefined in two ways. One is if I declared a variable but not given any value and another is I call a function that has to return nothing.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Q4: What is the meaning of == and ===?&lt;/strong&gt;&lt;br&gt;
Ans: == is slite restrict in checking two variables that are equal or not but not check their type. In ==== is restrict in checking two variables that are equal and also check their type.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Q5: What do you mean by block scope and functional scope?&lt;/strong&gt;&lt;br&gt;
Ans: A block scope is an area within if, switch conditions or for and while loops. Functional scope means the area within the function.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Q6: How you declare a private variable in JavaScript and what is encapsulation?&lt;/strong&gt;&lt;br&gt;
Ans: Private property of an object is declared using  _ adding at the first position of a variable. &lt;br&gt;
Ans: A group of related variables and functions seems to be a unit where the variables are called property and functions are call methods And this process is called encapsulation.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Q7: What is the meaning of this keyword in js and how you understand it?&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Ans: In javascript, this refers to the object that it belongs to. In a function, this refers to the global object ( in browser this refers to window object ). In method call or property call, this refers to the left side object of &lt;code&gt;.&lt;/code&gt; notation.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Q8: Tell detail about the call, bind, apply?&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Ans: If I want to bind an external function to an object I use the &lt;code&gt;call()&lt;/code&gt; method to the function. If I want to bind an external function to an object I also use &lt;code&gt;apply()&lt;/code&gt; method to the function. The difference between &lt;code&gt;call()&lt;/code&gt; and &lt;code&gt;apply()&lt;/code&gt; is that the second parameter of the &lt;code&gt;apply()&lt;/code&gt; is an array. Bind also works the same style as &lt;code&gt;call()&lt;/code&gt; but it returns a function.&lt;/p&gt;

</description>
      <category>javascript</category>
    </item>
    <item>
      <title>All About React</title>
      <dc:creator>Rahul Saha</dc:creator>
      <pubDate>Fri, 07 May 2021 14:45:27 +0000</pubDate>
      <link>https://dev.to/rahulsaha28/all-about-react-8ik</link>
      <guid>https://dev.to/rahulsaha28/all-about-react-8ik</guid>
      <description>&lt;p&gt;&lt;strong&gt;React JSX&lt;/strong&gt;: react jsx is neither a string nor an HTML tag. It's a powerful thing where we can use all javascript power.  We can create HTML elements using javascript.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;let element = document.createElement("h3")
element.innerText = "hi Rahul"
document.getElementById("app").appendChild(element)
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;In this process, we can create Html element using js. In the backend react is automatically creates the element in this process.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;import React from 'react';
const element = React.createElement('h1', null, "Hello Rahul");
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Here element is a valid JavaScript object. so we can do anything with it. We can write in a more simple way like this&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;import React from "react";
const element = &amp;lt;h3&amp;gt;Hello Rahul&amp;lt;/h3&amp;gt;;
console.log(element);
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Now JSX means javascript XML that looks like this up code and this conversion happen using babel&lt;br&gt;
We can use javascript in jsx inside &lt;code&gt;{}&lt;/code&gt; notation . We can set attribute in jsx like HTML tag.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;ReactDOM.render(element,  document.getElementById("app"))
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;this line shows the react element in the HTML page. if we change the element like then the code looks like&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;import React from "react";
import ReactDOM from "react-dom";
setInterval(() =&amp;gt; {
const element = (
&amp;lt;h3 className="h3"&amp;gt;
&amp;lt;span&amp;gt;
Hi Rahul
{Date()}
&amp;lt;/span&amp;gt;
&amp;lt;/h3&amp;gt;
);
ReactDOM.render(element, document.getElementById("app"));
}, 1000);
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Browser DOM:&lt;/strong&gt;&lt;br&gt;
&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fu7yrv2exr6as24vdtlqr.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fu7yrv2exr6as24vdtlqr.png" alt="Alt Text"&gt;&lt;/a&gt;&lt;br&gt;
This is the HTML rendering process in the browser. If we change something on the page it will rerender the page each change. So if we rerender the page it will slow the browser.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Batch update&lt;/strong&gt;: Batch update is an update process where first all update happens then render the page at last.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Virtual DOM&lt;/strong&gt;: In this process, a replica of the main dom is created and which is a javascript object. If something is changed in the dom react graph the change using reconciliation algorithm and find the change.&lt;br&gt;
&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Furj0skieaeu7m9c9bukj.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Furj0skieaeu7m9c9bukj.png" alt="Alt Text"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;useState()&lt;/strong&gt;: useState is a function that controls the state of the react component. Here state means the data that change for each update. This is called the state of a react element.&lt;/p&gt;

</description>
      <category>react</category>
      <category>hook</category>
    </item>
    <item>
      <title>JavaScript</title>
      <dc:creator>Rahul Saha</dc:creator>
      <pubDate>Fri, 07 May 2021 09:13:37 +0000</pubDate>
      <link>https://dev.to/rahulsaha28/javascript-4j1m</link>
      <guid>https://dev.to/rahulsaha28/javascript-4j1m</guid>
      <description>&lt;p&gt;&lt;strong&gt;Primitive VS function and Object&lt;/strong&gt;: primitive is that data type that has no methods like string, number, boolean, null, undefined, bigint. But function and object are also represented value but they are not primitive. All of these represent data of different types in javascript. type of()is a function. this function takes one parameter and finds the type of that parameter.&lt;br&gt;
&lt;strong&gt;javascript event loop&lt;/strong&gt;: &lt;br&gt;
&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--lce2m1h4--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/x2o8h4n2vthvafiravf5.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--lce2m1h4--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/x2o8h4n2vthvafiravf5.png" alt="Alt Text"&gt;&lt;/a&gt;&lt;br&gt;
This is the bigger picture of the JavaScript engine. We all know that all programming language work line by line that's means up to bottom. So if somewhere of the code a big loop is defined( like while or for) then it take time to execute and it can block the whole browser so we can not click at that movement. this is the blocking behavior of javascript. We all know that javascript is a single threat language. That means it can do one task at a time. Now call about stack you can think it's like a container that reserves the task and then resolves it. But if we want to work using javascript in a non-blocking way we use the async way. Some web API functions work in this way like setInterval(). it passes from stack to web API and waits there and all other tasks are resolved at this time so no blocking happens. after all, the task finish in the stack then the setInterval passes to the callback queue and an event loop always checks if the stack is empty or not if it finds empty it pushes the task from the callback queue to the stack.&lt;br&gt;
&lt;strong&gt;Error handling&lt;/strong&gt;: error happens when data loads from some form or somewhere else like ajax calls. Where use try and catch statement to handle the error. The try statement check if there is any error happens the catch statement catch the error and handle the error and the throw statement throws the customer error and finally statement execute the code after try and catch regardless of the result. &lt;br&gt;
&lt;strong&gt;Comment and Coding style&lt;/strong&gt;: comment is not related to coding but relates to understanding your code to others. it is used in javascript by using &lt;code&gt;// or /**/&lt;/code&gt;.&lt;br&gt;
Coding style is more important for better understanding. in debugging not use console.log for array use console. table()&lt;br&gt;
If we want to find where some task is happening like delete or edit use console. trace() to find which line the task is happening.&lt;br&gt;
In a function argument if pass an object and inside the function, if we use the property of the object use restructure, and that makes the code clear.&lt;br&gt;
In string concatenation use backtrack and use the symbol ${} that is more effective.&lt;br&gt;
Use function if the same task can do much time that skips the redundancy of the code. &lt;br&gt;
If we want to update the object property or add more property use spread syntax. This syntax is also used for the array.&lt;br&gt;
For handling array use the modern JavaScript array method.&lt;br&gt;
Use async and await for loading data from server to client without using promise and then.&lt;br&gt;
Block Bindings:  let is block scope and var is function scope. Global function and global variable are attached to the window object &lt;br&gt;
&lt;strong&gt;Hoisting&lt;/strong&gt;: Hoisting means to lift up and actually it does this.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;console.log(a)
var a= "Bangladesh";
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;the output is undefined. Then what actually happens? when we declare the variable with var we actually take two types of work one is the declaration and the other is the assigning a value. This actually happens in the JavaScript runtime engine. The JavaScript runtime engine first javascript runtime engine declare all variable so if a variable is declared but not assign a value then if console.log it shows undefined.&lt;br&gt;
&lt;br&gt;
 &lt;/p&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;var language1 = "JAVA";
var language2 = "JS";
function getLanguage() {
if (!language1) {
var language1 = language2;
}
return language1;
}
console.log(getLanguage());
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;


&lt;p&gt;Do you tell me what is the output of this code? So hoisting defined the variable at the top of its scope. This hoisting not only works on a variable but also a function too.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;console.log(sust)
const  sust = ()=&amp;gt;{
myfun = "hi";
var myfun = "si"
console.log(myfun);
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;what is the output? here also use hoisting.&lt;br&gt;
This hoisting all about the js execution pattern. JavaScript runs two stapes one is compilation state and then execution state.&lt;br&gt;
&lt;strong&gt;Default parameter&lt;/strong&gt;: if a function takes a parameter but when we call the function without giving the parameter value then we get an error. So for escape from error, we can set a default value for that parameter.&lt;br&gt;
&lt;strong&gt;Spread operator&lt;/strong&gt;: … is called the spread operator. it can edit, delete, add elements of an array.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;let v = [1,2,3]
let c = [...v,4,5,6,7]
console.log(c)
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;spread operator can also use an object in the same way. spread operator copy the existing array or object because in JavaScript object and array is a reference type. &lt;br&gt;
&lt;strong&gt;Higher-order function&lt;/strong&gt;: first we understand what is functional programming in js? if a function takes a function as a parameter and returns a function then this process is called functional programming. &lt;br&gt;
&lt;strong&gt;first-class function&lt;/strong&gt;: in js function is a special type of object. Because this function has some property also.&lt;br&gt;
&lt;strong&gt;Arrow function&lt;/strong&gt;: it simplifies the function decoration and understands. if the callBack function is a normal function then it changes this inside the function and sets the global context. But arrow function can not change this value&lt;/p&gt;

</description>
      <category>javascript</category>
    </item>
  </channel>
</rss>
