<?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: MD IMRUL MOLLA</title>
    <description>The latest articles on Forem by MD IMRUL MOLLA (@imrul099).</description>
    <link>https://forem.com/imrul099</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%2F1174815%2F4ad987da-6ef9-437e-8948-7284fb4c80b2.jpeg</url>
      <title>Forem: MD IMRUL MOLLA</title>
      <link>https://forem.com/imrul099</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://forem.com/feed/imrul099"/>
    <language>en</language>
    <item>
      <title>Explaining ‘this’ keyword in JavaScript</title>
      <dc:creator>MD IMRUL MOLLA</dc:creator>
      <pubDate>Mon, 08 Jul 2024 05:26:32 +0000</pubDate>
      <link>https://forem.com/imrul099/explaining-this-keyword-in-javascript-15hm</link>
      <guid>https://forem.com/imrul099/explaining-this-keyword-in-javascript-15hm</guid>
      <description>&lt;h2&gt;
  
  
  1. Global Context
&lt;/h2&gt;

&lt;p&gt;When used in the global context (outside of any function), this refers to the global object, which is window in browsers and global in Node.js.&lt;br&gt;
&lt;code&gt;console.log(this); // In a browser, this logs the Window object&lt;br&gt;
&lt;/code&gt;&lt;/p&gt;
&lt;h2&gt;
  
  
  2. Function Context
&lt;/h2&gt;

&lt;p&gt;In a regular function, the value of this depends on how the function is called.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;a. Function Invocation&lt;/strong&gt;&lt;br&gt;
When a function is called as a standalone function, this refers to the global object (in non-strict mode) or undefined (in strict mode).&lt;br&gt;
&lt;/p&gt;

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

foo(); // In non-strict mode, logs the global object (Window in browsers)
       // In strict mode, logs undefined

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

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;b. Method Invocation&lt;/strong&gt;&lt;br&gt;
When a function is called as a method of an object, this refers to the object the method is called on.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;const obj = {
  method: function() {
    console.log(this);
  }
};

obj.method(); // Logs the obj object

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

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;c. Constructor Invocation&lt;/strong&gt;&lt;br&gt;
When a function is used as a constructor (with the new keyword), this refers to the newly created object.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;function Person(name) {
  this.name = name;
}

const person = new Person('Alice');
console.log(person.name); // Logs 'Alice'

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

&lt;/div&gt;



&lt;h2&gt;
  
  
  3. Arrow Functions
&lt;/h2&gt;

&lt;p&gt;Arrow functions (=&amp;gt;) do not have their own this binding. Instead, this is lexically inherited from the outer function where the arrow function is defined.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;const obj = {
  regularFunction: function() {
    console.log(this); // Logs obj

    const arrowFunction = () =&amp;gt; {
      console.log(this); // Logs obj because it inherits `this` from regularFunction
    };

    arrowFunction();
  }
};

obj.regularFunction();

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

&lt;/div&gt;



&lt;h2&gt;
  
  
  4. Event Handlers
&lt;/h2&gt;

&lt;p&gt;In DOM event handlers, this refers to the element that received the event.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;document.getElementById('myButton').addEventListener('click', function() {
  console.log(this); // Logs the button element
});

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

&lt;/div&gt;



&lt;h2&gt;
  
  
  5. Explicit Binding
&lt;/h2&gt;

&lt;p&gt;JavaScript provides methods to explicitly set the value of this using call, apply, and bind.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;a. call and apply&lt;/strong&gt;&lt;br&gt;
call and apply methods call a function with a specified this value and arguments. The difference between them is how they handle arguments.&lt;br&gt;
&lt;/p&gt;

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

const person = { name: 'Alice' };

greet.call(person, 'Hello'); // Logs 'Hello, Alice'
greet.apply(person, ['Hi']); // Logs 'Hi, Alice'

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

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;b. bind&lt;/strong&gt;&lt;br&gt;
bind creates a new function that, when called, has its this keyword set to the provided value.&lt;br&gt;
&lt;/p&gt;

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

const person = { name: 'Alice' };
const boundGreet = greet.bind(person);

boundGreet(); // Logs 'Alice'

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

&lt;/div&gt;



&lt;h2&gt;
  
  
  Summary
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;Global context:&lt;/strong&gt; this refers to the global object.&lt;br&gt;
&lt;strong&gt;Function context:&lt;/strong&gt;&lt;br&gt;
Regular function: this is the global object or undefined in strict mode.&lt;br&gt;
Method: this is the object the method belongs to.&lt;br&gt;
Constructor: this is the new object being created.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Arrow functions&lt;/strong&gt;: this is lexically inherited from the outer function.&lt;br&gt;
&lt;strong&gt;Event handlers:&lt;/strong&gt; this is the event target element.&lt;br&gt;
&lt;strong&gt;Explicit binding:&lt;/strong&gt; Use call, apply, and bind to explicitly set this.&lt;/p&gt;

</description>
      <category>javascript</category>
      <category>webdev</category>
      <category>frontend</category>
      <category>programming</category>
    </item>
    <item>
      <title>Guideline for Front End Web Developer</title>
      <dc:creator>MD IMRUL MOLLA</dc:creator>
      <pubDate>Mon, 15 Jan 2024 10:21:34 +0000</pubDate>
      <link>https://forem.com/imrul099/guideline-for-front-end-web-developer-3787</link>
      <guid>https://forem.com/imrul099/guideline-for-front-end-web-developer-3787</guid>
      <description>&lt;p&gt;Front-end web development is the development of the graphical user interface of a website, through the use of HTML, CSS, and JavaScript, so that users can view and interact with that website.&lt;br&gt;
. Here's a simplified guideline for Front End Web Developer:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;Learn HTML and CSS:&lt;/strong&gt;

&lt;ul&gt;
&lt;li&gt;Understand the structure (HTML) and styling (CSS) of web pages.&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Master JavaScript:&lt;/strong&gt;

&lt;ul&gt;
&lt;li&gt;Learn the fundamentals, including variables, functions, and loops.&lt;/li&gt;
&lt;li&gt;Understand DOM manipulation for dynamic content.&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Version Control/Git:&lt;/strong&gt;

&lt;ul&gt;
&lt;li&gt;Learn Git for version control to manage code changes.&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Responsive Design:&lt;/strong&gt;

&lt;ul&gt;
&lt;li&gt;Understand how to make websites responsive using CSS media queries.&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;CSS Pre-processing:&lt;/strong&gt;

&lt;ul&gt;
&lt;li&gt;Learn a CSS pre-processor like Sass or Less for more efficient styling.&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Build Tools:&lt;/strong&gt;

&lt;ul&gt;
&lt;li&gt;Familiarize yourself with build tools like Webpack for bundling and minification.&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Frameworks/Libraries:&lt;/strong&gt;

&lt;ul&gt;
&lt;li&gt;Learn popular front-end libraries/frameworks like React, Angular, or Vue.js.&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Package Managers:&lt;/strong&gt;

&lt;ul&gt;
&lt;li&gt;Understand package managers like npm or Yarn.&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Browser Developer Tools:&lt;/strong&gt;

&lt;ul&gt;
&lt;li&gt;Master browser developer tools for debugging and optimizing code.&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Basic Graphic Design:&lt;/strong&gt;

&lt;ul&gt;
&lt;li&gt;Gain basic design skills for creating visually appealing interfaces.&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Cross-Browser Development:&lt;/strong&gt;

&lt;ul&gt;
&lt;li&gt;Ensure compatibility with various browsers.&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;APIs and RESTful Services:&lt;/strong&gt;

&lt;ul&gt;
&lt;li&gt;Learn how to fetch and handle data from APIs.&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Web Performance Optimization:&lt;/strong&gt;

&lt;ul&gt;
&lt;li&gt;Optimize websites for speed and performance.&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Testing/Debugging:&lt;/strong&gt;

&lt;ul&gt;
&lt;li&gt;Understand testing principles and tools (e.g., Jest).&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Basic SEO:&lt;/strong&gt;

&lt;ul&gt;
&lt;li&gt;Learn SEO principles for better search engine visibility.&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Web Accessibility:&lt;/strong&gt;

&lt;ul&gt;
&lt;li&gt;Ensure your websites are accessible to users with disabilities.&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Progressive Web Apps (PWAs):&lt;/strong&gt;

&lt;ul&gt;
&lt;li&gt;Explore creating PWAs for enhanced user experiences.&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Continuous Learning:&lt;/strong&gt;
Stay updated on new technology
&lt;img src="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Ftndtswj34m0qz1wvx59y.jpg" alt="Image description" width="800" height="368"&gt;
&lt;/li&gt;
&lt;/ol&gt;

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