<?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: Samss Jubair</title>
    <description>The latest articles on DEV Community by Samss Jubair (@samssjubair).</description>
    <link>https://dev.to/samssjubair</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%2F627278%2Fad41637d-aace-4f6d-bba1-453871f5548d.jpeg</url>
      <title>DEV Community: Samss Jubair</title>
      <link>https://dev.to/samssjubair</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/samssjubair"/>
    <language>en</language>
    <item>
      <title>10 Javascript Very Basic Interview Questions You Should Know</title>
      <dc:creator>Samss Jubair</dc:creator>
      <pubDate>Sat, 08 May 2021 15:46:17 +0000</pubDate>
      <link>https://dev.to/samssjubair/10-javascript-interview-questions-you-should-know-2hc0</link>
      <guid>https://dev.to/samssjubair/10-javascript-interview-questions-you-should-know-2hc0</guid>
      <description>&lt;blockquote&gt;
&lt;p&gt;This article is especially for beginners who are looking for Job as a Javascript Developer. I have searched a lot of Javascript interview questions and these 10 seem most important to me. Let's dig into this a bit.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;h2&gt;
  
  
  1. What is Javascript?
&lt;/h2&gt;

&lt;p&gt;Javascript is a programming language that is used for Web Development. JavaScript runs on the client-side of the web.&lt;/p&gt;

&lt;p&gt;According to MDN JavaScript (often shortened to JS) is a lightweight, interpreted, object-oriented language with first-class functions, and is best known as the scripting language for Web pages, but it's used in many non-browser environments as well. It is a prototype-based, multi-paradigm scripting language that is dynamic, and supports object-oriented, imperative, and functional programming styles.&lt;/p&gt;

&lt;h2&gt;
  
  
  2. What is DOM
&lt;/h2&gt;

&lt;p&gt;DOM stands for Document Object Model. When a web page is loaded the browser creates a DOM using the HTML and CSS file. The DOM is represented by nodes and elements. You can manipulate DOM using javascript. It's a tree-like structure.&lt;/p&gt;

&lt;h2&gt;
  
  
  3. How JS Code is Executed
&lt;/h2&gt;

&lt;p&gt;It's a bit large question to answer in an Interview. But we can say it briefly. Javascript runs on the browser. There's a javascript engine for almost every browser. V8 is the most popular of them. Chrome uses the V8 engine. On the other hand, Firefox uses the Spider-Monkey engine.&lt;/p&gt;

&lt;h2&gt;
  
  
  4. Difference between == and ===
&lt;/h2&gt;

&lt;p&gt;If I say this shortly, == only checks if both values are the same or not. It doesn't check the type of these values. Check out the code below:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;if(2=="2"){
 console.log("true")
} else {
console.log("false")
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The above code will log true. Because it treats both 2 and "2" as equal as it doesn't check the types.&lt;/p&gt;

&lt;p&gt;On the contrary === checks both type and quality. For instance:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;if(2==="2"){
 console.log("true")
} else {
console.log("false")
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This will log false. Because 2 and "2" are equal by values but they are of different types.&lt;/p&gt;

&lt;h2&gt;
  
  
  5. Null vs Undefined
&lt;/h2&gt;

&lt;p&gt;Generally, null means empty and non-existent value while undefined means something that is declared but not defined yet. Though you can explicitly set undefined to a variable too.&lt;br&gt;
&lt;/p&gt;

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

var n = null;
console.log(typeof(n)); // object
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Interestingly null is an object type in JS.&lt;/p&gt;

&lt;h2&gt;
  
  
  6. Var vs Let vs Const
&lt;/h2&gt;

&lt;p&gt;Before ES6 var was the only way to declare a variable. But now we have more options. &lt;/p&gt;

&lt;p&gt;There is a term as scope. Scope means where these variables are available for use. var declarations are globally scoped or function/locally scoped.&lt;/p&gt;

&lt;p&gt;Var can be hoisted which we will discuss a few seconds later. But now let is more preferable for variable declarations. You can use const when there is no need to change a variable later in the code. To get the difference between this you can read the following article which I found pretty useful.&lt;/p&gt;

&lt;h2&gt;
  
  
  7. Hoisting
&lt;/h2&gt;

&lt;p&gt;In javascript, a variable can be used before it has been declared. The concept of variable and function declarations to physically moved to the top of your code is called hoisting.&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(num); // Returns undefined, as only declaration was hoisted, no initialization has happened at this stage
var num; // Declaration
num = 6; 
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;So are let and const variables not hoisted? The answer is a bit more complicated than that. All declarations (function, var, let, const, and class) are hoisted in JavaScript, while the var declarations are initialized with undefined, but let and const declarations remain uninitialized.&lt;/p&gt;

&lt;h2&gt;
  
  
  8. Global vs Local Scope
&lt;/h2&gt;

&lt;p&gt;In javascript, scopes are divided in two ways. Local and global.&lt;br&gt;
Variables declared in the function are called local scope. That variable can't be accessed outside of the function. On the contrary, variables declared outside of a function are called global scope. it can be accessed inside the function.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;var genre= "superhero" //global scope
// code here can't use superhero but genre
function myFunction() {
  var superhero = "Batman"; // local scope

  // code here CAN use superhero and genre

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

&lt;/div&gt;



&lt;h2&gt;
  
  
  9. Closure
&lt;/h2&gt;

&lt;p&gt;A closure gives us access to an outer function’s scope from an inner function. It can be created by returning another function from a function. It creates a close environment for each instance. 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;function sum(x) {
  return function(y) {
    return x + y;
  };
}

var add5 = sum(5);
var add10 = sum(10);

console.log(add5(6));  // 11
console.log(add10(6)); // 16
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Here add5 and add10 are both closures. They share the same definition but store different environments.  To know more about closures you can follow the link below:&lt;br&gt;
&lt;a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Closures"&gt;https://developer.mozilla.org/en-US/docs/Web/JavaScript/Closures&lt;/a&gt;&lt;/p&gt;
&lt;h2&gt;
  
  
  10. Callback Function
&lt;/h2&gt;

&lt;p&gt;According to MDN, A callback function is a function passed into another function as an argument, which is then invoked inside the outer function to complete some kind of routine or action. For instance&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;function greeting(name) {
  console.log('Hello ' + name);
}

function greetEmployee(name,callback) {

  callback(name);
}

greetEmployee("Dwight",greeting);
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Here the greeting function has been used inside the greetEmployee function. This is what we call a callback function. Follow &lt;a href="https://www.w3schools.com/js/js_callback.asp"&gt;this&lt;/a&gt; to grasp more about js callback.&lt;/p&gt;

&lt;p&gt;Thanks for reading this. Hope this will help you.&lt;/p&gt;

&lt;p&gt;Stay in touch&lt;br&gt;
Happy coding &lt;/p&gt;

</description>
      <category>javascript</category>
      <category>webdev</category>
      <category>programming</category>
    </item>
    <item>
      <title>10 Things You Need To Learn About Before Starting ReactJS</title>
      <dc:creator>Samss Jubair</dc:creator>
      <pubDate>Fri, 07 May 2021 15:54:47 +0000</pubDate>
      <link>https://dev.to/samssjubair/10-things-you-need-to-learn-about-before-starting-reactjs-1nkp</link>
      <guid>https://dev.to/samssjubair/10-things-you-need-to-learn-about-before-starting-reactjs-1nkp</guid>
      <description>&lt;blockquote&gt;
&lt;p&gt;Millions of developers use ReactJS. If you are new to React development or willing to start it, this article might help you. Here are my top 10 things you should know definitely about react.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;h2&gt;
  
  
  1. Is React a library or framework?
&lt;/h2&gt;

&lt;p&gt;It's a common question among newbies. Rather I have seen some people working with react who think it's a framework. &lt;/p&gt;

&lt;p&gt;For the record, It's a library. A framework is theoretically a larger thing comparing to a library. A library is more flexible when it is compared to a framework. You have more control over it. &lt;/p&gt;

&lt;p&gt;React is comparatively small than frameworks like Angular, Vue, Laravel, or Django. &lt;/p&gt;

&lt;h2&gt;
  
  
  2. What is ReactJS actually?
&lt;/h2&gt;

&lt;p&gt;It's an open-source javascript library for frontend development. It was created and developed by Facebook. ReacrtJS is extremely popular nowadays for creating single-page web applications.&lt;/p&gt;

&lt;h2&gt;
  
  
  3. Why React?
&lt;/h2&gt;

&lt;p&gt;React provides better performance and better user experience compared to other frameworks. It uses reusable components that reduce a lot of pain for frontend developers. It's fast and SEO-friendly. ReactJS guarantees quicker rendering. It's also easy to learn. &lt;/p&gt;

&lt;p&gt;Another exciting thing is you can use React for both Android and ios app development by using React-Native. Before heading to ReactJS I was passionate about android app development. This feature excited me the most to learn ReactJS.&lt;/p&gt;

&lt;h2&gt;
  
  
  4. JSX
&lt;/h2&gt;

&lt;p&gt;React introduces us to JSX. JSX is a syntax extension of Javascript. You can write HTML inside your Javascript code using JSX.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;const element = &amp;lt;h1&amp;gt;ROXANNE&amp;lt;/h1&amp;gt;;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Instead of writing markups and logic in separate files, react introduces us to JSX. Browsers don't understand JSX, to translate JSX with browser understandable JS we need a transpiler. For example Babel and Transcripts.&lt;/p&gt;

&lt;p&gt;To know more about it read the article below&lt;br&gt;
&lt;a href="https://reactjs.org/docs/introducing-jsx.html"&gt;https://reactjs.org/docs/introducing-jsx.html&lt;/a&gt;&lt;/p&gt;
&lt;h2&gt;
  
  
  5. The Virtual DOM
&lt;/h2&gt;

&lt;p&gt;You may hear the word DOM (Document Object Model) if you have some previous frontend developing experience. DOM treats HTML as a tree structure. We can modify the DOM using JS. If you modify anything in the DOM the whole tree structures get updated. It can consume a decent amount of time if you are working with a large application.&lt;/p&gt;

&lt;p&gt;You can learn more about DOM if you are interested from [here]{&lt;a href="http://taligarsiel.com/Projects/howbrowserswork1.htm#Parsing_general"&gt;http://taligarsiel.com/Projects/howbrowserswork1.htm#Parsing_general&lt;/a&gt;}&lt;/p&gt;

&lt;p&gt;React introduces us to the Virtual Dom. Whenever any changes occur in V DOM it does not update the whole DOM. It rather compares the change with the previous version of DOM using Diffing algorithm. Then it applies the reconciliation process to update the UI. It's one of the coolest features of ReactJS in my opinion. You can learn more about this from the URL below: &lt;br&gt;
&lt;a href="https://medium.com/@gethylgeorge/how-virtual-dom-and-diffing-works-in-react-6fc805f9f84e"&gt;https://medium.com/@gethylgeorge/how-virtual-dom-and-diffing-works-in-react-6fc805f9f84e&lt;/a&gt;&lt;/p&gt;
&lt;h2&gt;
  
  
  6. Components
&lt;/h2&gt;

&lt;p&gt;A react application is all about components in my eyes. You can create reusable components which can be used as an HTML element wherever you need it. You can use two types of components in ReactJS. Functional and Class-based.&lt;/p&gt;

&lt;p&gt;Class-based components are slightly out of date. If you want to learn reactJS now I'll suggest you learn functional components first.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;function Welcome() {
  return &amp;lt;h1&amp;gt;Hello, How you doin?&amp;lt;/h1&amp;gt;;
}

function App() {
  return (
    &amp;lt;div&amp;gt;
      &amp;lt;Welcome/&amp;gt;
      &amp;lt;Welcome/&amp;gt;
      &amp;lt;Welcome/&amp;gt;
    &amp;lt;/div&amp;gt;
  );
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Here Welcome is a component that has been used three times. You can divide your react application into a lot of components like this. You can get a clear idea about this from the link below: &lt;br&gt;
&lt;a href="https://reactjs.org/docs/components-and-props.html"&gt;https://reactjs.org/docs/components-and-props.html&lt;/a&gt;&lt;/p&gt;
&lt;h2&gt;
  
  
  7. Props
&lt;/h2&gt;

&lt;p&gt;HTML elements can have some properties like title, placeholder, etc. You can also use this type of thing in react. It's called the props. You can pass some data while declaring your component just like you declare HTML properties. 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;function Welcome(props) {
  return &amp;lt;h1&amp;gt;Hello, {props.name}&amp;lt;/h1&amp;gt;;
}

function App() {
  return (
    &amp;lt;div&amp;gt;
      &amp;lt;Welcome name="Michael" /&amp;gt;
      &amp;lt;Welcome name="Dwight" /&amp;gt;
      &amp;lt;Welcome name="Jim" /&amp;gt;
    &amp;lt;/div&amp;gt;
  );
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Here we are passing different names for each Welcome component like we are passing HTML property. Using props we can send different data to components to build UI.&lt;/p&gt;

&lt;p&gt;to learn more about props follow this URL &lt;a href="https://reactjs.org/docs/components-and-props.html"&gt;https://reactjs.org/docs/components-and-props.html&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  9. Hooks
&lt;/h2&gt;

&lt;p&gt;A Hook is a special function that lets you “hook into” React features. For example, useEffect, useState, useRef, useContext, useReducer etc. If you want to use functional components to develop ReactJS applications hook is something you can't ignore.&lt;br&gt;
You can follow the article below to know more about hooks.&lt;br&gt;
&lt;a href="https://reactjs.org/docs/hooks-state.html"&gt;https://reactjs.org/docs/hooks-state.html&lt;/a&gt;&lt;/p&gt;
&lt;h2&gt;
  
  
  10. State
&lt;/h2&gt;

&lt;p&gt;State is a special react feature that reduces a lot of pain for the developer for changing the UI. Here we will discuss briefly the useState method. First, have a peek at the following code&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, { useState } from 'react';

function Example() {
  // Declare a new state variable, which we'll call "count"
  const [count, setCount] = useState(0);

  return (
    &amp;lt;div&amp;gt;
      &amp;lt;p&amp;gt;You clicked {count} times&amp;lt;/p&amp;gt;
      &amp;lt;button onClick={() =&amp;gt; setCount(count + 1)}&amp;gt;
        Click me
      &amp;lt;/button&amp;gt;
    &amp;lt;/div&amp;gt;
  );
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The useState hook returns a pair of values: the current state and a function that updates it.  In class component we use  this.state.count and this.setState for similar reason. The value of the state can be updated using the setState method. To learn more about useState hooks follow the link below:&lt;br&gt;
&lt;a href="https://reactjs.org/docs/hooks-state.html"&gt;https://reactjs.org/docs/hooks-state.html&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;I guess this is all for today. This is my first article in dev.to&lt;br&gt;
Inspire me to continue writing. Thanks for reading this&lt;/p&gt;

&lt;p&gt;&lt;em&gt;Happy coding!&lt;/em&gt;&lt;/p&gt;

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