<?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: Praveen Alluri</title>
    <description>The latest articles on DEV Community by Praveen Alluri (@ipa22751).</description>
    <link>https://dev.to/ipa22751</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%2F915763%2F1826a807-fdca-44f4-add2-6a2b077cc07e.png</url>
      <title>DEV Community: Praveen Alluri</title>
      <link>https://dev.to/ipa22751</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/ipa22751"/>
    <language>en</language>
    <item>
      <title>React JS Basics</title>
      <dc:creator>Praveen Alluri</dc:creator>
      <pubDate>Tue, 01 Nov 2022 19:18:53 +0000</pubDate>
      <link>https://dev.to/ipa22751/react-js-basics-46lj</link>
      <guid>https://dev.to/ipa22751/react-js-basics-46lj</guid>
      <description>&lt;h3&gt;
  
  
  What is React JS?
&lt;/h3&gt;

&lt;p&gt;React is a javascript library to create a (UI) user interface based on UI Components. Jordan Walke created it at Facebook in 2011. They made it open source in 2013. React is one of the most used JS libraries to create web-based applications.&lt;br&gt;
The DOM updates can be managed with ease by React. It's a lightweight and speedy library for implementing JS applications with scalability and reusable code. It uses less memory to keep the representation of virtual DOM elements.&lt;/p&gt;

&lt;p&gt;Let me introduce the vocabulary in the javascript world.&lt;/p&gt;
&lt;h3&gt;
  
  
  What are .JS and .JSX files?
&lt;/h3&gt;

&lt;p&gt;JavaScript code is included in JS (JavaScript) files, which run JavaScript on web pages. The &lt;code&gt;.Js&lt;/code&gt; extension is used to hold JavaScript files. If the JS file has the HTML code and Javascript code, it's called &lt;code&gt;.JSX&lt;/code&gt; (JS XML files or JS HTML files.)&lt;/p&gt;
&lt;h3&gt;
  
  
  React -DOM?
&lt;/h3&gt;

&lt;p&gt;In order to provide an effective approach to controlling DOM components of the web page, ReactDOM is a package that offers DOM-specific functions that can be used at the top level of a web application. &lt;/p&gt;

&lt;p&gt;The following methods are available in ReactDOM's API for developers.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;render()&lt;/li&gt;
&lt;li&gt;findDOMNode()&lt;/li&gt;
&lt;li&gt;unmountComponentAtNode()&lt;/li&gt;
&lt;li&gt;hydrate()&lt;/li&gt;
&lt;li&gt;createPortal()&lt;/li&gt;
&lt;/ul&gt;
&lt;h3&gt;
  
  
  Babel
&lt;/h3&gt;

&lt;p&gt;A JavaScript transpiler called BabelJS converts new features into out-of-date standards. This makes it simple to use the functionalities on both outdated and modern browsers. Sebastian McKenzie, an Australian programmer, founded BabelJS.&lt;/p&gt;

&lt;p&gt;We require a program that will build our final code in ES5 if we want to leverage new ECMA Script capabilities and run it on any accessible browser.&lt;/p&gt;

&lt;p&gt;The same thing is done by Babel, which is referred to as a transpiler that transpiles the code into the desired ECMA Script version.&lt;/p&gt;
&lt;h3&gt;
  
  
  COMPONENTS
&lt;/h3&gt;

&lt;p&gt;The vital part of the &lt;code&gt;React&lt;/code&gt; application is &lt;code&gt;components.&lt;/code&gt; a component is a piece of (UI) user interface. When we build web applications, we build independent, reusable components. Then we use all these components to build a complex UI. Every react application has one root component. This root component has child components and an internal application. so every react application is a tree of components.&lt;br&gt;
For example, if we take the FB page as a web application project, we split this application into components like Navbar, Feed, and profile,  so the feed component has several child components such as like, share components, and these are reusable components which means you can use these components in somewhere else or sometimes in different applications. &lt;/p&gt;

&lt;p&gt;Component implemented as a javascript &lt;code&gt;class&lt;/code&gt;, and some &lt;code&gt;state&lt;/code&gt;, &lt;code&gt;render&lt;/code&gt; method.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;`State` is the data we want to display when the component is rendered.

`Render method` is responsible for describing how UI should look like.

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The output of the render method is a react element, which is a simple JS object mapped to a virtual-DOM element. When we change the state of a component, then we get a new react element. Then will compare this element and its children with the previous one to find out the changed one, and it will update in the real DOM to keep it synchronized with the virtual DOM. &lt;/p&gt;

&lt;p&gt;That means when building applications with reactJS, unlike &lt;code&gt;Jquery&lt;/code&gt; and &lt;code&gt;vanilla JS,&lt;/code&gt; we no longer have to work with DOM API in browsers.&lt;/p&gt;

&lt;h3&gt;
  
  
  Real-time Environment
&lt;/h3&gt;

&lt;p&gt;Let's build the basic configurations for creating react applications in real time.&lt;/p&gt;

&lt;p&gt;Go to your terminal and run the below command.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;create-react-app &amp;lt;name of the app&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;It will automatically install react and all other third-party libraries we need. It will install a development server, Webpack for files, babel for compiling JS code, and other tools. all config will be done for you. You don't need to do anything. You can customize this configuration per your organization's environment needs.&lt;/p&gt;

&lt;p&gt;Let's go to our app &lt;code&gt;myapp&lt;/code&gt; and run NPM start (Node Package Manager). It will launch a development server on port 3000 on your local browser.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;cd myapp

npm start 
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--QwHo3JKg--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/czrqd7rnf3ybxyy8gc2r.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--QwHo3JKg--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/czrqd7rnf3ybxyy8gc2r.png" alt="Image description" width="880" height="500"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Let's go back to our editor to see what kind of folders we got.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--jT6Lfbq_--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/6r6zxpd6tgrvjmtqannr.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--jT6Lfbq_--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/6r6zxpd6tgrvjmtqannr.png" alt="Image description" width="496" height="1040"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Here we have three folders. &lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;&lt;code&gt;node_Modules&lt;/code&gt;: It will have all third-party libraries.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;code&gt;Public&lt;/code&gt;: This folder holds public assets of the application, including &lt;code&gt;index.html.&lt;/code&gt;&lt;/p&gt;

&lt;ul&gt; {} mainfest.json: You utilize mainfest.json files to construct PWAs (Progressive Web Apps).&lt;/ul&gt;

&lt;ul&gt; robots.txt: It helps to prevent search engines from accessing your website. &lt;/ul&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;code&gt;src:&lt;/code&gt; The raw source code files are kept in this folder before minification. It's the heart of our APP.&lt;/p&gt;

&lt;ul&gt; app.js: this is the first thing your browser will load inside `index.js.`&lt;/ul&gt;

&lt;ul&gt; setupTests.js: As suggested by the name, this file sets up and executes tests. When we run tests from the CLI, this file is directly called (npm run test).&lt;/ul&gt;

&lt;ul&gt; **package-lock.json**: will show all installed package versions.&lt;/ul&gt;

&lt;ul&gt; package.json: it will show all installed packages by NPM.
&lt;ul&gt; reportWebVitals: With the reportWebVitals function, you can send any results to an analytics endpoint to measure and track real user performance on your site. &lt;/ul&gt;
&lt;/ul&gt;


&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Below highlighted markup code inside the javascript file is .jsx (javascript XML), which is responsible for how UI looks.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--pcMdJ_c_--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/17dtegf3k89w2lan8sny.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--pcMdJ_c_--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/17dtegf3k89w2lan8sny.png" alt="Image description" width="880" height="804"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;The output looks like the above image ( 3: browser output image).&lt;/p&gt;

&lt;p&gt;As we mentioned earlier, babel works as a compiler. To understand this code, babel turns this JSX code into pure javascript code for the browser to understand. Check the below image for more understanding.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--TW-UAIry--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/8v4o7108npt0hj7hajky.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--TW-UAIry--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/8v4o7108npt0hj7hajky.png" alt="Image description" width="880" height="324"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;We will delete all those default files in the &lt;code&gt;SRC&lt;/code&gt; folder and build from scratch.&lt;/p&gt;

&lt;p&gt;Now my app is down. The first thing it will look for src folder is &lt;code&gt;Index.Js,&lt;/code&gt; so I will create a new index file.&lt;br&gt;
And I run the below commands.&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";

const Home = &amp;lt;h1&amp;gt; Hello world &amp;lt;/h1&amp;gt;;

ReactDOM.render (Home, document.getElementById("root"));
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Now my web app is up and running. We will make a little tweak to this file for better understanding.&lt;br&gt;
We will create a component that can be reusable, and you can call or use it as many times as you need.&lt;br&gt;
So I will create a subfolder called &lt;code&gt;components&lt;/code&gt; inside &lt;code&gt;src&lt;/code&gt;, and I will also create an App.js file inside this components folder. and I will insert the below code into App.js. Now the app will run smoothly without errors using components.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;function App() {
    return &amp;lt;h1&amp;gt; Hello world &amp;lt;/h1&amp;gt;;
 }

 export default App;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;So This is it. These are the basics or an intro to react world. in real time it will be much fun with little difficulty. &lt;/p&gt;

&lt;p&gt;Enjoy the rest of the day, Folks... Cheers! &lt;/p&gt;

</description>
      <category>iwritecode</category>
      <category>react</category>
      <category>reactnative</category>
      <category>javascript</category>
    </item>
    <item>
      <title>JavaScript Interview Crib Notes</title>
      <dc:creator>Praveen Alluri</dc:creator>
      <pubDate>Thu, 22 Sep 2022 02:48:21 +0000</pubDate>
      <link>https://dev.to/ipa22751/javascript-interview-crib-notes-2aho</link>
      <guid>https://dev.to/ipa22751/javascript-interview-crib-notes-2aho</guid>
      <description>&lt;p&gt;This article will explain the *&lt;em&gt;Scope,  Single Thread, Call Stack, and Hoisting *&lt;/em&gt; concepts to reduce confusion during interviews. Similar to a brief reminder before an interview.&lt;/p&gt;

&lt;h2&gt;
  
  
  What are scopes in JavaScript?
&lt;/h2&gt;

&lt;p&gt;As the name says, the scope is nothing but "the extent of the area." In other words, its limitations.&lt;br&gt;
In terms of coding, where is the variable declared? And from where can it be accessed?&lt;br&gt;
It's simple, right, so now we will discuss why and what those limitations are or Scopes.&lt;br&gt;
There are three essential Scopes in JS. One is the &lt;code&gt;Global level&lt;/code&gt; Scope, the second is the &lt;code&gt;Function level,&lt;/code&gt; and the &lt;code&gt;Block level&lt;/code&gt; Scope. &lt;/p&gt;
&lt;h3&gt;
  
  
  Global Scope
&lt;/h3&gt;

&lt;p&gt;In the global scope, the variables inside of this scope can be accessed from anywhere inside the JS application. Example:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="kd"&gt;var&lt;/span&gt; &lt;span class="nx"&gt;a&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;10&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="kd"&gt;let&lt;/span&gt; &lt;span class="nx"&gt;b&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;20&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

&lt;span class="kd"&gt;function&lt;/span&gt; &lt;span class="nf"&gt;write&lt;/span&gt; &lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="nx"&gt;console&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;log&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;b&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="nf"&gt;write&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Output:&lt;/p&gt;

&lt;p&gt;The above example shows that the variable can be accessed inside and outside a function/block.&lt;/p&gt;

&lt;p&gt;Here, only &lt;code&gt;a&lt;/code&gt; is visible under the window object. In a way, You can consider the Window object as a global scope. But we cannot view the &lt;code&gt;b&lt;/code&gt; from the above example. It uses the ** Let/const ** properties to declare a variable. However, &lt;code&gt;b&lt;/code&gt; can be accessed by calling the &lt;code&gt;write()&lt;/code&gt; function, which proves our global scope theory. Although using a global variable is not a good practice except in exceptional cases. You will know the reasons later in this article.&lt;/p&gt;

&lt;h3&gt;
  
  
  function scope
&lt;/h3&gt;

&lt;p&gt;you can also refer to the local scope; It is only accessible within the function. It can not access any variables/values declared outside the function. For an Example:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;var a = 10;
let b = 20;

function write () {
    var c = 30;
}

console.log(c); 
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Output:  you can see that when we try to print the &lt;code&gt;c&lt;/code&gt; value, it's throwing a reference error saying that &lt;code&gt;c&lt;/code&gt; is not defined. Because we declared the variable &lt;code&gt;c&lt;/code&gt; inside the function, it is not accessible outside of that function.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn.hashnode.com%2Fres%2Fhashnode%2Fimage%2Fupload%2Fv1663592766485%2F4YSX8UtuI.png%2520align%3D" 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%2Fcdn.hashnode.com%2Fres%2Fhashnode%2Fimage%2Fupload%2Fv1663592766485%2F4YSX8UtuI.png%2520align%3D" alt="Screenshot 2022-09-19 at 2.05.41 pm.png"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;The problem with &lt;code&gt;var&lt;/code&gt; is that if it is a for loop, while loop, if statement, switch statement, or any block asides of a function, it is not scoped locally. It works like a global scope except in &lt;strong&gt;function&lt;/strong&gt;. So we can say &lt;code&gt;var&lt;/code&gt; only has functional scope.&lt;br&gt;
For example:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;if (true) {
    var c = 'hello';
}

console.log(c)

Output: 
(base) praveenalluri@Praveens-MacBook-Air training % node test.js
hello

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;See, though defining &lt;code&gt;c&lt;/code&gt; inside a local scope/object, &lt;code&gt;c&lt;/code&gt; is still accessible outside the local scope. This may create name clash conflicts in your JS application. This is why let and const are introduced to address this issue in the form of block scope.&lt;/p&gt;

&lt;h3&gt;
  
  
  Blockscope
&lt;/h3&gt;

&lt;p&gt;So what is a block? Anything in between the curly braces is called a block. Unlike &lt;strong&gt;Var&lt;/strong&gt;, &lt;code&gt;LET/CONST&lt;/code&gt; are locally scoped. Not just to functions but all call blocks. So you can call &lt;strong&gt;LET&lt;/strong&gt; and &lt;strong&gt;CONST&lt;/strong&gt; are block scoped.&lt;br&gt;
Let's see a real-time example.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;let a = 10;

if(true) {
    let a = 2000;
    console.log(a);
}
console.log(a);

Output: 
(base) praveenalluri@Praveens-MacBook-Air training % node test.js
2000
10
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;In the above example, you can see that there is no name conflict though we defined &lt;code&gt;a&lt;/code&gt; twice using &lt;strong&gt;LET/CONST&lt;/strong&gt;. That's because the inside block scope variable &lt;code&gt;a&lt;/code&gt; doesn't know or can not access the outside variable &lt;code&gt;a&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;That's all about scopes related to Var, Let, and Const in Javascript. The scope is all about where the program uses the variable.&lt;/p&gt;

&lt;p&gt;Let's move to our next topic, Single Thread.&lt;/p&gt;

&lt;h2&gt;
  
  
  Is Javascript Single threaded Async language?
&lt;/h2&gt;

&lt;p&gt;In fact, JavaScript is a single-threaded synchronous language with asynchronous capabilities. It means In the core of JS, it works synchronously. However, we do have asynchronous capabilities. We have web APIs that can help us do things asynchronously. In JS, one thread of execution runs at a time, and this has caused confusion among some people. Let's understand with this a simple demo.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;function hi(){
setTimeout(() =&amp;gt; {
    console.log('hi number 1')
}, 1000);
};

hi();
console.log('hi number 2')

Output:
(base) praveenalluri@Praveens-MacBook-Air training % node test.js
hi number 2
hi number 1
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;If you see the above code, it started executing the first line of code and all those declarations. Later it called function &lt;code&gt;hi()&lt;/code&gt; and it called &lt;code&gt;set timeout&lt;/code&gt; and then passed the parameters. It past something that says hey! Here's some code to be executed later, and here's the timeout. But it doesn't run that last, get queued up somewhere. (you will learn how and where it's storing those values later in this article).&lt;br&gt;
There is some event Queue that was eventually going to process this. It's scheduled for execution in about 1000 milliseconds. And finally, it is called &lt;code&gt;console.log(hi number 2)&lt;/code&gt;. So our application started up. It wrote console.log(), a second went by, and hi() executed.&lt;/p&gt;

&lt;p&gt;Now, I will add some confusion to the code. I will add something into the main threaded execution that will never have a chance to process the things in the event queue. I'm adding a while loop with no parameters.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn.hashnode.com%2Fres%2Fhashnode%2Fimage%2Fupload%2Fv1663629512730%2Fd7F6J1xsp.png%2520align%3D" 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%2Fcdn.hashnode.com%2Fres%2Fhashnode%2Fimage%2Fupload%2Fv1663629512730%2Fd7F6J1xsp.png%2520align%3D" alt="Screenshot 2022-09-20 at 12.18.17 am.png"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Now we run it again, and I got my &lt;code&gt;hi number 2&lt;/code&gt;, and I never get &lt;code&gt;hi number 1&lt;/code&gt;, and that's to be expected if you understand how this works. This is queued up as soon as the system has time to process the event Queue it will process. But our main thread execution is stuck right now, just doing nothing. Now there's a technique that you should know about JS. There are times when you do have to do things that will take a long time, and you do want to allow your javascript to process items that are queued up that are ready to run. Let's understand this with a small demo.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn.hashnode.com%2Fres%2Fhashnode%2Fimage%2Fupload%2Fv1663780799009%2FJLdxafyJj.png%2520align%3D" 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%2Fcdn.hashnode.com%2Fres%2Fhashnode%2Fimage%2Fupload%2Fv1663780799009%2FJLdxafyJj.png%2520align%3D" alt="Screenshot 2022-09-21 at 6.08.04 pm.png"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Like before, this will get stuck; however, it gets stuck by putting things in the event queue. So think about this, It will execute the same things before it looks at your 'console.log(hi)', and it will call a function that will call this set timer and execute the set timeout right away. And then queue up something for execution later. So we'll get stuck in this loop, but it's going through the events queue now. If it's something else on the event queue, it will have an opportunity to run. &lt;/p&gt;

&lt;p&gt;In simple words, when I run this above code, It gives the output value &lt;code&gt;hi number 2&lt;/code&gt; followed by &lt;code&gt;hi number 1&lt;/code&gt;, and then it is stuck. Because even though we've put this lock-up function **"hi3()" **in the middle of our application. We're still going through the event queue and processing the other things in the event queue.&lt;br&gt;
That's it. I think you now understand the async and single-threaded concepts in javascript language.&lt;/p&gt;
&lt;h2&gt;
  
  
  call stack in JS
&lt;/h2&gt;

&lt;p&gt;A call stack keeps track of our functions. It is a stack of functions it manages, which we call the execution contexts. At the bottom of the call stack is our global execution context. That will always be at the bottom, and our functions will be stacked on top. A Stack is a data structure, so it doesn't have to be the JavaScript call stack. You can create any stack, just like in an array or queue. Stacks are LIFO which stands for “last in first out” what that means is the last thing in is always going to be the first thing out. Let's look at some sample code and what that would look like on the call stack.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;function one() {
  console.log("one");
  two();
}

function two() {
    console.log("two");
    three();
}

function three() {
    console.log("three");  
}

one();

Output: 
(base) praveenalluri@Praveens-MacBook-Air training % node test.js
one
two
three


&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Let's see the below example.&lt;/p&gt;

&lt;p&gt;%[&lt;a href="https://youtu.be/wdbIMqz4aM8" rel="noopener noreferrer"&gt;https://youtu.be/wdbIMqz4aM8&lt;/a&gt;]&lt;/p&gt;

&lt;p&gt;Now, I'm going into the sources tab and putting a breakpoint right at first where this whole thing starts, and I will reload the browser, so it's paused right now. You can see we have created the global execution context. It's in our call stack, and I'm going into the first function one(), so I'll click this arrow key on the right top. Now you can see that function &lt;code&gt;one&lt;/code&gt; pushed onto the stack. Then we're going to go to the console.log, and once again, I click this arrow key again, it's going to run function two(). So notice now that &lt;code&gt;one&lt;/code&gt; is still there. It means we're still in the first function, one(), because that's where two() is called, so two() is now on the stack and then call three() so click the arrow again, three() now three gets pushed onto the stack, and then I will go ahead and execute three() now it gets popped off, later two() that gets popped off and then one(). So it's always last in, first out, OK, so that's a pretty basic example of how the call stack works. As you build big projects, pop into the sources tab and look at the call stack. Obviously, it'll be much more complicated when you're working on an actual project.&lt;/p&gt;

&lt;h2&gt;
  
  
  Hoisting
&lt;/h2&gt;

&lt;p&gt;Hoisting is a phenomenon in JavaScript by which you can access these variables and functions even before you have initialized or given some value to them. You can access them without any errors. So wherever this let variable is present in the program, it does not matter; you can access it anywhere. So let me show you some examples.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;hoist();

console.log(x);

var x=7;

console.log(hoist);

function hoist(){
    console.log('hoisting test');
}

Output :
(base) praveenalluri@Praveens-MacBook-Air training % node test.js
hoisting test
undefined
[Function: hoist]

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;If you observe correctly, I called the function and variable before initializing them, but you can see the values in the output without errors. If it is any other programming language, it will throw an error. because hoisting concept in Javascript it wont throw any errors. When ever the Js program runs it creates &lt;code&gt;Global execution context&lt;/code&gt; which has two components, Memory and code. the first phase will be scan the entire JS program and allocate space to variables and functions in the memory component before executing the program. That is why our second result is saying undefined because it already allocated &lt;code&gt;undefined memory&lt;/code&gt;  to &lt;code&gt;x&lt;/code&gt; before knowing it's value.&lt;/p&gt;

&lt;p&gt;That's all folks. see you in the next article. Watch out for more space.&lt;/p&gt;

&lt;p&gt;Stay peace&lt;/p&gt;


&lt;p&gt;&lt;a href="https://giphy.com/gifs/bye-see-you-later-mP8GermRyOFWV8PQeq" rel="noopener noreferrer"&gt;&lt;/a&gt;&lt;/p&gt;

</description>
      <category>javascript</category>
      <category>webdev</category>
      <category>tutorial</category>
      <category>programming</category>
    </item>
    <item>
      <title>VAR vs LET vs CONST</title>
      <dc:creator>Praveen Alluri</dc:creator>
      <pubDate>Sat, 10 Sep 2022 23:17:01 +0000</pubDate>
      <link>https://dev.to/ipa22751/var-vs-let-vs-const-32op</link>
      <guid>https://dev.to/ipa22751/var-vs-let-vs-const-32op</guid>
      <description>&lt;h1&gt;
  
  
  Why not VAR?
&lt;/h1&gt;

&lt;p&gt;In general, the let keyword is used to declare variables. Although, there is another way to do it using the 'var' keyword. We find this in a lot of online JavaScript tutorials and blogs. We'll examine the var keyword in this article, and you'll learn about its drawbacks and reasons to stay away from it. So let's discuss Defining a function.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;function numbers() {
    for (let i = 0 ; i &amp;lt; 6 ; i++ ) {
        console.log(i);
    }
}
numbers();

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;In the above code, &lt;code&gt;i&lt;/code&gt; is only accessible inside &lt;code&gt;{ }&lt;/code&gt; the block. You will receive an error if you try to access &lt;code&gt;i&lt;/code&gt; outside of the block. Saying &lt;code&gt;i&lt;/code&gt; is not defined. See below code snippet for reference.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;function numbers() {
    for (let i = 0 ; i &amp;lt; 6 ; i++ ) {
        console.log(i);
    }

    console.log(i);
}
numbers(); 


//Output//

ReferenceError: i is not defined

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;To be clear, even if I remove these curly braces, the error will remain the same.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;function numbers() {
    for (let i = 0 ; i &amp;lt; 6 ; i++ ) 
        console.log(i);

    console.log(i);
}
numbers();

// output //

ReferenceError: i is not defined


&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Let's see what happens when we swap out "let" with "var." Apparently, 'I' is reachable outside of this block. The loop ends after the last iteration and displays the result.&lt;br&gt;
Hence, the problem with the &lt;code&gt;var&lt;/code&gt; keyword is. A variable's scope is not constrained to the block in which it is defined when it is declared with the var keyword. It is restricted to the function level. It is one of those peculiar things that JavaScript has long possessed. From ES6, commonly known as ES 2015, two new keywords are introduced, &lt;code&gt;let&lt;/code&gt; and &lt;code&gt;const&lt;/code&gt;, to generate variables and constants. These two keywords produce block-scoped variables, whereas &lt;code&gt;var&lt;/code&gt; creates function-scoped variables.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;function numbers() {
    for (var i = 0 ; i &amp;lt; 6 ; i++ ) 
        console.log(i);

    console.log(i);
}
numbers();

// output //

0
1
2
3
4
5
6
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;There is another issue with &lt;code&gt;Var&lt;/code&gt; concerning global variables.&lt;br&gt;
Avoid using global variables or use them sparingly in JavaScript. This is due to the ease with which other scripts can replace global variables. Although they are not inherently evil or particularly security-related, global variables shouldn't override the values of other variables. A maintenance problem might arise if we use more global variables in our code. Consider the case when the same-named variable was added. Prepare yourself for some significant bugs in that situation. Use local variables and enclose your code in closures to prevent using global variables. &lt;code&gt;Var&lt;/code&gt; variables can be reassigned multiple times by re-declaring the variable.&lt;/p&gt;

&lt;p&gt;In other words, One of the biggest problems with the &lt;code&gt;var&lt;/code&gt; keyword for declaring variables is that it allows you to overwrite variables accidentally that you didn't mean to overwrite. Because usually, when you declare a variable with the keyword &lt;code&gt;var&lt;/code&gt; or &lt;code&gt;let&lt;/code&gt;, &lt;code&gt;constant&lt;/code&gt; you're thinking this is the first time this variable is being declared, so if you were able to overwrite variables by doing this, you might accidentally overwrite variables that you don't intend to which is the biggest problem with &lt;code&gt;var&lt;/code&gt; and &lt;code&gt;let&lt;/code&gt; takes care of that problem because it won't let us do that ever, which will save us from making those simple mistakes.&lt;/p&gt;

&lt;p&gt;&lt;code&gt;Const&lt;/code&gt; and &lt;code&gt;let&lt;/code&gt; are virtually identical, except that &lt;code&gt;const&lt;/code&gt; prevents you from redeclaring the variable. Thus, as an example.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;const name = 'praveen'
let name1 = 'alluri'

name = 'marthanda'
name1 = 'varma'

// output //

TypeError: Assignment to constant variable.
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;But &lt;code&gt;const&lt;/code&gt; allows us to change the properties of an object. For an example&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;const person = {name :'praveen'}
let name1 = 'alluri'

person.name = 'marthanda'
name1 = 'varma'

console.log(person)

// Output//

{ name: 'marthanda' }
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;As you can see, we don't truly experience an error. Const thus only stops us from modifying the variable's actual value or assigning it a new value but not changing different properties in that value. Const and let are pretty comparable so you may use them both. However, unless you need to modify the variable's value, I would advise using &lt;code&gt;const&lt;/code&gt; rather than &lt;code&gt;let&lt;/code&gt; since you can be sure you won't mistakenly change the value if you choose not to. That's the essential difference between &lt;code&gt;cost&lt;/code&gt;, &lt;code&gt;var&lt;/code&gt;, and &lt;code&gt;let&lt;/code&gt;. &lt;/p&gt;

&lt;p&gt;Because of this and several other factors, I believe you should nearly and always use &lt;code&gt;const&lt;/code&gt; and &lt;code&gt;let&lt;/code&gt; when defining variables unless you have a specific situation for doing so. Even in that instance, I strongly advise you to consider why you want to use &lt;code&gt;var&lt;/code&gt;. Because switching from using &lt;code&gt;var&lt;/code&gt; to &lt;code&gt;const&lt;/code&gt; or &lt;code&gt;let&lt;/code&gt; in your design is always preferable.&lt;/p&gt;

&lt;h3&gt;
  
  
  That's all, folks
&lt;/h3&gt;

&lt;p&gt;These are brief yet crucial lessons for our everyday work lives.&lt;/p&gt;

&lt;p&gt;Learn more things, and share most stuff... Easy life with no worries.&lt;/p&gt;

&lt;p&gt;Let's Rock!!!&lt;/p&gt;


&lt;p&gt;&lt;a href="https://giphy.com/gifs/from-review-exclusive-wUMyW0P54loc"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  Before you leave
&lt;/h3&gt;

&lt;p&gt;If you like the content, please follow my social hangouts for exciting discussions.&lt;/p&gt;

&lt;h3&gt;
  
  
  References
&lt;/h3&gt;

&lt;p&gt;&lt;a href="https://programmingwithmosh.com/"&gt;links&lt;/a&gt;&lt;/p&gt;

</description>
      <category>javascript</category>
      <category>webdev</category>
      <category>programming</category>
    </item>
    <item>
      <title>Why should you learn to &lt;/code&gt;</title>
      <dc:creator>Praveen Alluri</dc:creator>
      <pubDate>Thu, 08 Sep 2022 01:26:33 +0000</pubDate>
      <link>https://dev.to/ipa22751/why-should-you-learn-to-3d73</link>
      <guid>https://dev.to/ipa22751/why-should-you-learn-to-3d73</guid>
      <description>&lt;p&gt;Yes, you should learn code. Everyone should know the code. Even if you are not trying to change your career, WHY? It's the same question throughout history "Why should I educate myself?" Computers rank on par with humans regarding cognitive ability in this digital age. Yes! How a computer operates, and the human brain does are almost identical. Coding, then, aids in problem-solving and sharpens your reasoning skills. It will be 2x times higher if you are a woman as your brain can multitask. &lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--VmuW10Aa--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_66%2Cw_880/https://tenor.com/view/uptime-gif-20288826.gif" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--VmuW10Aa--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_66%2Cw_880/https://tenor.com/view/uptime-gif-20288826.gif" width="498" height="259"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;As &lt;code&gt;Artificial Intelligence&lt;/code&gt; is replacing humans in many jobs, You should be in a position to give instructions rather than taking one. At the very least, you must know what's happening around your programming world. We don't exist anymore without programming running around us. It's hard to avoid technology irrespective of your Background. Here are the reasons why you should code.&lt;/p&gt;

&lt;p&gt;&lt;code&gt;Work flexibility:&lt;/code&gt; The fact that you can work from home must make our ancestors jealous. It's time to say goodbye to 8 hours of dull office space! You can work from your couch. Avoiding the commute to work will save you a lot of time. You can do whatever fudge you want in that time. If you are married, well!... that's vice versa. &lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--yP9QyDeW--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_66%2Cw_880/https://tenor.com/view/ok-crying-sad-emotional-sentimental-gif-20646670.gif" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--yP9QyDeW--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_66%2Cw_880/https://tenor.com/view/ok-crying-sad-emotional-sentimental-gif-20646670.gif" width="498" height="498"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;code&gt;Money:&lt;/code&gt; There is a lot of money, dude, yes, a lot. Who doesn't like the money? That's the driving force of our boring busy lives. Isn't it? You can earn a lot of money by learning to program. You don't believe me. Check out the top billionaires. They all are tech firm founders. Techies can make a lot of money. Software Developers made a median salary of $110,140 a year. &lt;br&gt;
&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--oB72ZzGk--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_66%2Cw_880/https://tenor.com/view/tuzki-usagi-wink-counting-money-rich-green-gif-13764223.gif" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--oB72ZzGk--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_66%2Cw_880/https://tenor.com/view/tuzki-usagi-wink-counting-money-rich-green-gif-13764223.gif" width="240" height="220"&gt;&lt;/a&gt;&lt;br&gt;
Holy cow! Well, my young grasshopper, that's not the case for everyone. Hey, but compared to other industry engineers, you are making more money than a seasoned man.&lt;/p&gt;

&lt;p&gt;&lt;code&gt;Career Options:&lt;/code&gt; you got a lot of career options. Especially these covid times, You can easily land a job if you know how to code it. You can become a web designer, backend developer, App developer, Technical content writer, freelancer for programming jobs, YouTuber, Blogger, and Program manager. There are a ton lot of things you can do if you know how to code. &lt;/p&gt;

&lt;p&gt;&lt;code&gt;Automation:&lt;/code&gt; Yes, it's an underrated reason, but you can automate things you do regularly by using small scripts and, for example, checking your favorite merchandise on sale. An automated program checks those sites and lets you know when they are in the deal. Same for Data Entry, making groceries list, etc.&lt;/p&gt;

&lt;p&gt;This is my opinion to conclude. You are welcome to your thoughts, but I genuinely believe learning to code will open new doors in life. Happy Coding! Folks&lt;/p&gt;

&lt;p&gt;&lt;a href="https://yellowmultiverse.netlify.app/"&gt;My portfolio&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://www.instagram.com/ipa22751/"&gt;my insta&lt;/a&gt;&lt;/p&gt;

</description>
      <category>programming</category>
    </item>
    <item>
      <title>Array Methods In JS</title>
      <dc:creator>Praveen Alluri</dc:creator>
      <pubDate>Thu, 08 Sep 2022 00:35:30 +0000</pubDate>
      <link>https://dev.to/ipa22751/array-methods-in-js-15bk</link>
      <guid>https://dev.to/ipa22751/array-methods-in-js-15bk</guid>
      <description>&lt;h2&gt;
  
  
  What is Array?
&lt;/h2&gt;

&lt;p&gt;In simple terms, An ordered list of values makes up an array. The term "Element" designated by an index refers to each value.&lt;br&gt;
In another way, everything in square brackets becomes an array. Items inside an array are called elements. It can be boolean values or integer/numbers, floating values or string values, etc.&lt;/p&gt;
&lt;h2&gt;
  
  
  Array Methods
&lt;/h2&gt;

&lt;p&gt;There are many array methods, but I only cover the most used ones in this article.&lt;br&gt;
Array methods play a vital role in the JS programming world. If you master these methods, your soft life will be a cakewalk. There are many parameters in each array method. I'm discussing only the basics to understand their significance in the JS world.&lt;/p&gt;
&lt;h3&gt;
  
  
  array.filter()
&lt;/h3&gt;

&lt;p&gt;As the name says, the filter method will return specific elements from the array based on filter method properties.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;let people = [
    {name : 'jaan', height: 6.2 , weight : 85, haircolor: 'brown'} ,
    {name : 'shane', height: 5.11 , weight : 75, haircolor: 'black'},
    {name : 'praveen', height: 6.1 , weight : 79, haircolor: 'black'},
    {name : 'marco', height: 5.9 , weight : 80, haircolor: 'brown'},
    {name : 'kim', height: 5.6 , weight : 67, haircolor: 'black'},
];

let result = people.filter (feature =&amp;gt; feature.haircolor == 'black');

console.log(result)

# output : [
  { name: 'shane', height: 5.11, weight: 75, haircolor: 'black' },
  { name: 'praveen', height: 6.1, weight: 79, haircolor: 'black' },
  { name: 'kim', height: 5.6, weight: 67, haircolor: 'black' }
]
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Here, I filtered the elements in the array called &lt;code&gt;people&lt;/code&gt; based on the hair color property.&lt;/p&gt;

&lt;p&gt;&lt;code&gt;callbackfn:&lt;/code&gt; Any function passed as an argument to another function so that it can be executed in that other function is called a callback function. You can see this in the above example.&lt;/p&gt;

&lt;p&gt;Many JavaScript operations are asynchronous, which means that unlike how you're probably used to them, they don't stop the program (or a function) from running until they're finished. For this reason, callback functions are necessary. Instead, while the rest of the code runs, it will run in the background.&lt;/p&gt;

&lt;h3&gt;
  
  
  array.find()
&lt;/h3&gt;

&lt;p&gt;This method returns the first satisfying element value in the array among the other elements based on index position.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;let x = [1,2,4,3,6,9]

let y = x.find(element =&amp;gt; element &amp;gt; 2);

console.log(y)

# output: 4

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;As per the math theory, the "3" should be the answer, but if we observe the array index positioning, "4" is on the 2nd index, and "3" is on the 3rd index; hence the answer is 4.&lt;/p&gt;

&lt;h3&gt;
  
  
  array.forEach()
&lt;/h3&gt;

&lt;p&gt;The forEach() method iterates through an array's items while calling a function. Maps and Sets can both be utilized using the forEach() method.&lt;/p&gt;

&lt;p&gt;Note: There is no way to stop or break a forEach() loop other than by throwing an exception. If you need such behavior, the forEach() method is the wrong tool.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;let x =[2,4,7,3];
let y = x.forEach(z =&amp;gt; console.log(z+2));

#output: 
4
6
9
5
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  array.every()
&lt;/h3&gt;

&lt;p&gt;The &lt;code&gt;every&lt;/code&gt; method determines if every component satisfies the requirement. The method only returns true after that. False is given if just one element fails the test.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;let x =[5,4,12,3];
let y = x.every(z =&amp;gt; z&amp;gt;10);
console.log(y)

# output: false
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Each element should satisfy the condition mentioned in every() method. Then it results as a &lt;code&gt;true&lt;/code&gt; output. If any element in the array fails to meet the requirement, this returns &lt;code&gt;false.&lt;/code&gt;  In the above example, not all the numbers are greater than ten; hence the output is false.&lt;/p&gt;

&lt;h3&gt;
  
  
  array.some()
&lt;/h3&gt;

&lt;p&gt;&lt;code&gt;some&lt;/code&gt; is a special array method. It tests whether at least one element within the array tests positive for a specific condition. If so, some returns true; otherwise, it returns false.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;let x =[5,4,12,3];
let y = x.some(z =&amp;gt; z&amp;gt;10);
console.log(y)

# output: true
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;code&gt;some()&lt;/code&gt; is the other way around of every() method. &lt;/p&gt;

&lt;h3&gt;
  
  
  array.includes()
&lt;/h3&gt;

&lt;p&gt;In simple terms, &lt;code&gt;includes&lt;/code&gt; works like a checklist. It will check whether the element is present in the array or not. Based on the result, it returns true or false. It contains the exact matching of an object.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;let x =['Ramesh', 'suresh', 'mahesh', 'naresh', 'Rajesh',]
let y = x.includes('ramesh');
console.log(y)

#output : false
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;If you observe close enough, the condition is not met in the above example. As I said, it follows the strict equality principle. The case sensitivity is the reason for the False result in the above example.&lt;/p&gt;

&lt;h3&gt;
  
  
  array.map()
&lt;/h3&gt;

&lt;p&gt;One of the most significant array techniques available is &lt;code&gt;map.&lt;/code&gt; It is the method to use if you wish to alter every value in 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 x =[5,4,12,3];
let y = x.map(z =&amp;gt; z*2);
console.log(y)


output: [ 10, 8, 24, 6 ]
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;So &lt;code&gt;y&lt;/code&gt; is the whole new array now holding the above output elements, and &lt;code&gt;x&lt;/code&gt; is still the same. It won't change any element in the &lt;code&gt;x&lt;/code&gt; array. It only uses the elements to form a new array.&lt;/p&gt;

&lt;h3&gt;
  
  
  array.reduce()
&lt;/h3&gt;

&lt;p&gt;The most effective array approach currently in use is &lt;code&gt;reduce()&lt;/code&gt; It is the most versatile and may be used to reimplement all current array methods. It would require a whole post to discuss all the benefits it provides, but you will quickly get a taste of it.&lt;/p&gt;

&lt;p&gt;Returning the total of an array's elements may be the simplest use case for reduce().&lt;br&gt;
Example:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;let x =[5,4,12,3];
let z= 1;
let y = x.reduce((ftvalue,sdvalue) =&amp;gt; ftvalue + sdvalue,z );
console.log(y)

output: 25
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The backend operation of the above example is 1+5+4+12+3 = 25&lt;/p&gt;

&lt;p&gt;&lt;code&gt;reduce&lt;/code&gt; is difficult to understand. It does the same as all other array methods, &lt;code&gt;reduce&lt;/code&gt; iterates through every element. The procedure must first determine whether an initialValue was provided. If not, the array's first element is assumed to be such. The callback's output is then substituted for the accumulator each time it is called and is ultimately returned in its complete form.&lt;/p&gt;

&lt;h3&gt;
  
  
  array.sort()
&lt;/h3&gt;

&lt;p&gt;The name already tells you everything. This technique must always be used if you wish to sort 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 x =[22,45,17,81,23,15,93,54,36,75];
let y = x.sort();
console.log(y);

output:  [
  15, 17, 22, 23, 36,
  45, 54, 75, 81, 93
]
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The default sort order is ascending, built upon converting the elements into strings and comparing their UTF-16 code unit value sequences.&lt;/p&gt;

&lt;h3&gt;
  
  
  array.findIndex()
&lt;/h3&gt;

&lt;p&gt;You may use the function &lt;code&gt;findindex()&lt;/code&gt; to determine an element's index inside an array. Similar to find, it ends at the first element that meets the requirement. Thus, it will never return anything other than the index of the first element that passes the test.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;let x =[22,45,17,81,23,15,93,54,36,75];
let y = x.findIndex(z =&amp;gt; z&amp;gt;70);
console.log(y)

output: 3
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Here, the condition satisfies the 4th element in the array. Its index is &lt;code&gt;3&lt;/code&gt; as indexing starts from&lt;code&gt;0.&lt;/code&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  That's It for now
&lt;/h3&gt;

&lt;p&gt;you have now learned some most used array methods in javascript. They are all similar to miner distinguishes. Once you understand the significance, you will know where and how to use them. &lt;/p&gt;

&lt;h3&gt;
  
  
  Before you leave
&lt;/h3&gt;

&lt;p&gt;If you like the content, please follow my social hangouts for exciting discussions.&lt;/p&gt;

&lt;p&gt;That's it all, folks... Keep Learning &amp;amp; Keep Sharing !!! &lt;/p&gt;

&lt;p&gt;Cheers&lt;br&gt;
&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--PxQyc35T--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_66%2Cw_880/https://tenor.com/view/cheers-emoji-smiles-gif-15302237.gif" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--PxQyc35T--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_66%2Cw_880/https://tenor.com/view/cheers-emoji-smiles-gif-15302237.gif" width="498" height="468"&gt;&lt;/a&gt; &lt;/p&gt;

&lt;h3&gt;
  
  
  References
&lt;/h3&gt;

&lt;p&gt;&lt;a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array"&gt;link&lt;/a&gt;&lt;/p&gt;

</description>
      <category>javascript</category>
      <category>arraymethods</category>
      <category>beginners</category>
      <category>webdev</category>
    </item>
  </channel>
</rss>
