<?xml version="1.0" encoding="utf-8" standalone="yes"?><rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom"><channel><title>Javascript on Ghafoor's Personal Blog</title><link>http://ghafoorsblog.com/categories/javascript/</link><description>Recent content in Javascript on Ghafoor's Personal Blog</description><generator>Hugo</generator><language>en</language><managingEditor>noreply@example.com (AG Sayyed)</managingEditor><webMaster>noreply@example.com (AG Sayyed)</webMaster><copyright>Copyright © 2024-2026 AG Sayyed. All Rights Reserved.</copyright><lastBuildDate>Thu, 16 Apr 2026 17:17:05 +0100</lastBuildDate><atom:link href="http://ghafoorsblog.com/categories/javascript/index.xml" rel="self" type="application/rss+xml"/><item><title>Javascript Apis</title><link>http://ghafoorsblog.com/courses/ibm/fullstack-content/fullstack-pcert/03-html-css-js/03-module/005-javascript-api/</link><pubDate>Mon, 24 Mar 2025 13:01:47 +0000</pubDate><author>noreply@example.com (AG Sayyed)</author><guid>http://ghafoorsblog.com/courses/ibm/fullstack-content/fullstack-pcert/03-html-css-js/03-module/005-javascript-api/</guid><description>&lt;p class="lead text-primary"&gt; 
This document explains how to work with JavaScript APIs to manipulate HTML elements and nodes. It covers methods for retrieving, creating, and modifying elements, as well as managing window objects and events to enhance web page interactivity. 
&lt;/p&gt;


&lt;hr&gt;
&lt;h2 id="javascript-apis"&gt;JavaScript APIs&lt;/h2&gt;
&lt;p&gt;An API, or Application Programming Interface, is a mechanism that allows two systems to communicate with each other. It acts as a messenger that takes your request to another system, such as a server or database, and delivers the response back to you.&lt;/p&gt;</description></item><item><title>JavaScript Functions</title><link>http://ghafoorsblog.com/courses/ibm/fullstack-content/fullstack-pcert/03-html-css-js/03-module/004-functions/</link><pubDate>Mon, 24 Mar 2025 10:04:34 +0000</pubDate><author>noreply@example.com (AG Sayyed)</author><guid>http://ghafoorsblog.com/courses/ibm/fullstack-content/fullstack-pcert/03-html-css-js/03-module/004-functions/</guid><description>&lt;p class="lead text-primary"&gt; 
This document explains JavaScript functions, prototypes, and self-executing functions. It covers how functions are declared, how prototypes simplify the addition of properties and methods to objects, and how self-executing functions isolate variables and initialize data. 
&lt;/p&gt;


&lt;hr&gt;
&lt;h2 id="javascript-functions"&gt;JavaScript Functions&lt;/h2&gt;
&lt;h3 id="function-declaration-and-usage"&gt;Function Declaration and Usage&lt;/h3&gt;
&lt;ul&gt;
&lt;li&gt;A function is a block of reusable code that can be called after being declared.&lt;/li&gt;
&lt;li&gt;Functions consist of:
&lt;ul&gt;
&lt;li&gt;The &lt;code&gt;function&lt;/code&gt; keyword.&lt;/li&gt;
&lt;li&gt;A name for the function.&lt;/li&gt;
&lt;li&gt;Parentheses for optional parameters.&lt;/li&gt;
&lt;li&gt;Curly braces containing the logic.&lt;/li&gt;
&lt;li&gt;An optional &lt;code&gt;return&lt;/code&gt; statement to return a value.&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;h3 id="example-function-declaration"&gt;Example: Function Declaration&lt;/h3&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-javascript" data-lang="javascript"&gt;&lt;span class="line"&gt;&lt;span class="ln"&gt;1&lt;/span&gt;&lt;span class="cl"&gt;&lt;span class="kd"&gt;function&lt;/span&gt; &lt;span class="nx"&gt;add&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;a&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&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="ln"&gt;2&lt;/span&gt;&lt;span class="cl"&gt; &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="nx"&gt;a&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="nx"&gt;b&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="ln"&gt;3&lt;/span&gt;&lt;span class="cl"&gt;&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="ln"&gt;4&lt;/span&gt;&lt;span class="cl"&gt;&lt;span class="nx"&gt;console&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;log&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;add&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;5&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;10&lt;/span&gt;&lt;span class="p"&gt;))&lt;/span&gt; &lt;span class="c1"&gt;// Output: 15
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;ul&gt;
&lt;li&gt;Functions in JavaScript are loosely typed, meaning the data type of arguments is determined at runtime.&lt;/li&gt;
&lt;li&gt;Functions can return different types based on the input, such as adding numbers or concatenating strings.&lt;/li&gt;
&lt;/ul&gt;
&lt;hr&gt;
&lt;h2 id="javascript-prototypes"&gt;JavaScript Prototypes&lt;/h2&gt;
&lt;h3 id="overview-of-prototypes"&gt;Overview of Prototypes&lt;/h3&gt;
&lt;ul&gt;
&lt;li&gt;Prototypes allow properties and methods to be shared across all instances of an object.&lt;/li&gt;
&lt;li&gt;Objects created with the &lt;code&gt;new&lt;/code&gt; keyword inherit properties and methods from their prototype.&lt;/li&gt;
&lt;/ul&gt;
&lt;h3 id="example-using-prototypes"&gt;Example: Using Prototypes&lt;/h3&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-javascript" data-lang="javascript"&gt;&lt;span class="line"&gt;&lt;span class="ln"&gt; 1&lt;/span&gt;&lt;span class="cl"&gt;&lt;span class="kd"&gt;function&lt;/span&gt; &lt;span class="nx"&gt;Car&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;make&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;model&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;year&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="ln"&gt; 2&lt;/span&gt;&lt;span class="cl"&gt; &lt;span class="k"&gt;this&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;make&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;make&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="ln"&gt; 3&lt;/span&gt;&lt;span class="cl"&gt; &lt;span class="k"&gt;this&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;model&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;model&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="ln"&gt; 4&lt;/span&gt;&lt;span class="cl"&gt; &lt;span class="k"&gt;this&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;year&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;year&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="ln"&gt; 5&lt;/span&gt;&lt;span class="cl"&gt;&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="ln"&gt; 6&lt;/span&gt;&lt;span class="cl"&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="ln"&gt; 7&lt;/span&gt;&lt;span class="cl"&gt;&lt;span class="nx"&gt;Car&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;prototype&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;getName&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="kd"&gt;function&lt;/span&gt; &lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="ln"&gt; 8&lt;/span&gt;&lt;span class="cl"&gt; &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="sb"&gt;`&lt;/span&gt;&lt;span class="si"&gt;${&lt;/span&gt;&lt;span class="k"&gt;this&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;make&lt;/span&gt;&lt;span class="si"&gt;}&lt;/span&gt;&lt;span class="sb"&gt; &lt;/span&gt;&lt;span class="si"&gt;${&lt;/span&gt;&lt;span class="k"&gt;this&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;model&lt;/span&gt;&lt;span class="si"&gt;}&lt;/span&gt;&lt;span class="sb"&gt; (&lt;/span&gt;&lt;span class="si"&gt;${&lt;/span&gt;&lt;span class="k"&gt;this&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;year&lt;/span&gt;&lt;span class="si"&gt;}&lt;/span&gt;&lt;span class="sb"&gt;)`&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="ln"&gt; 9&lt;/span&gt;&lt;span class="cl"&gt;&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="ln"&gt;10&lt;/span&gt;&lt;span class="cl"&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="ln"&gt;11&lt;/span&gt;&lt;span class="cl"&gt;&lt;span class="kr"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;car1&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;new&lt;/span&gt; &lt;span class="nx"&gt;Car&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s1"&gt;&amp;#39;Toyota&amp;#39;&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s1"&gt;&amp;#39;Corolla&amp;#39;&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;2020&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="ln"&gt;12&lt;/span&gt;&lt;span class="cl"&gt;&lt;span class="nx"&gt;console&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;log&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;car1&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;getName&lt;/span&gt;&lt;span class="p"&gt;())&lt;/span&gt; &lt;span class="c1"&gt;// Output: Toyota Corolla (2020)
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;ul&gt;
&lt;li&gt;Adding a method to a prototype ensures all instances of the object inherit the method.&lt;/li&gt;
&lt;li&gt;Changes to the prototype are reflected in all instances.&lt;/li&gt;
&lt;/ul&gt;
&lt;hr&gt;
&lt;h2 id="self-executing-functions"&gt;Self-Executing Functions&lt;/h2&gt;
&lt;h3 id="what-are-self-executing-functions"&gt;What Are Self-Executing Functions&lt;/h3&gt;
&lt;ul&gt;
&lt;li&gt;Self-executing functions, also known as auto-invocation or immediately invoked function expressions (IIFE), run immediately after being declared.&lt;/li&gt;
&lt;li&gt;These functions isolate variables and logic from the global scope.&lt;/li&gt;
&lt;/ul&gt;
&lt;h3 id="example-self-executing-function"&gt;Example: Self-Executing Function&lt;/h3&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-javascript" data-lang="javascript"&gt;&lt;span class="line"&gt;&lt;span class="ln"&gt;1&lt;/span&gt;&lt;span class="cl"&gt;&lt;span class="p"&gt;;(&lt;/span&gt;&lt;span class="kd"&gt;function&lt;/span&gt; &lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="ln"&gt;2&lt;/span&gt;&lt;span class="cl"&gt; &lt;span class="kr"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;message&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="s1"&gt;&amp;#39;Hello, World!&amp;#39;&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="ln"&gt;3&lt;/span&gt;&lt;span class="cl"&gt; &lt;span class="nx"&gt;console&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;log&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;message&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="ln"&gt;4&lt;/span&gt;&lt;span class="cl"&gt;&lt;span class="p"&gt;})()&lt;/span&gt; &lt;span class="c1"&gt;// Output: Hello, World!
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;ul&gt;
&lt;li&gt;Self-executing functions are often used for initialization tasks or to declare DOM elements.&lt;/li&gt;
&lt;li&gt;Variables and functions inside an IIFE are not accessible outside of it.&lt;/li&gt;
&lt;/ul&gt;
&lt;hr&gt;
&lt;h2 id="conclusion"&gt;Conclusion&lt;/h2&gt;
&lt;p&gt;JavaScript functions provide reusable blocks of code, while prototypes simplify the addition of shared properties and methods to objects. Self-executing functions isolate logic and variables, making them useful for initialization and encapsulation.&lt;/p&gt;</description></item><item><title> JavaScript Control Statements</title><link>http://ghafoorsblog.com/courses/ibm/fullstack-content/fullstack-pcert/03-html-css-js/03-module/003-js-control-statements/</link><pubDate>Mon, 24 Mar 2025 03:33:44 +0000</pubDate><author>noreply@example.com (AG Sayyed)</author><guid>http://ghafoorsblog.com/courses/ibm/fullstack-content/fullstack-pcert/03-html-css-js/03-module/003-js-control-statements/</guid><description>&lt;p class="lead text-primary"&gt;
This document explains JavaScript control statements, including conditional statements like "if" and "switch", and loops like "for", "while", and "do-while". It demonstrates how these statements enable developers to control program flow and create dynamic web applications.
&lt;/p&gt;


&lt;hr&gt;
&lt;h2 id="javascript-control-statements"&gt;JavaScript Control Statements&lt;/h2&gt;
&lt;p&gt;Control statements in JavaScript allow developers to &lt;code&gt;direct program flow&lt;/code&gt; based on conditions and execute code repeatedly using loops. These statements help create dynamic and interactive web applications by enabling efficient data handling and user interaction.&lt;/p&gt;</description></item><item><title>Javascript Variables</title><link>http://ghafoorsblog.com/courses/ibm/fullstack-content/fullstack-pcert/03-html-css-js/03-module/002-javascript-variables/</link><pubDate>Mon, 24 Mar 2025 03:28:07 +0000</pubDate><author>noreply@example.com (AG Sayyed)</author><guid>http://ghafoorsblog.com/courses/ibm/fullstack-content/fullstack-pcert/03-html-css-js/03-module/002-javascript-variables/</guid><description>&lt;p class="lead text-primary"&gt; 
This document explains JavaScript variables, their declaration, initialization, and scope, as well as control statements like conditional statements, switch statements, and loops. It highlights how these features enable dynamic program flow and efficient data handling in JavaScript. 
&lt;/p&gt;


&lt;hr&gt;
&lt;h2 id="javascript-variables"&gt;JavaScript Variables&lt;/h2&gt;
&lt;h3 id="declaration-and-initialization"&gt;Declaration and Initialization&lt;/h3&gt;
&lt;ul&gt;
&lt;li&gt;Variables are &lt;code&gt;declared&lt;/code&gt; using the &lt;code&gt;var&lt;/code&gt; keyword followed by the variable name, e.g., &lt;code&gt;var age&lt;/code&gt;.&lt;/li&gt;
&lt;li&gt;Variables can be initialized during declaration, e.g., &lt;code&gt;var age = 54&lt;/code&gt;, or assigned a value later.&lt;/li&gt;
&lt;li&gt;JavaScript is &lt;code&gt;loosely typed&lt;/code&gt;, so variables take their data type from the assigned value and can change type during execution.&lt;/li&gt;
&lt;li&gt;Uninitialized variables have a value of &lt;code&gt;undefined&lt;/code&gt;.&lt;/li&gt;
&lt;/ul&gt;
&lt;h3 id="rules-for-variable-names"&gt;Rules for Variable Names&lt;/h3&gt;
&lt;ul&gt;
&lt;li&gt;Must start with a letter, underscore (&lt;code&gt;_&lt;/code&gt;), or dollar sign (&lt;code&gt;$&lt;/code&gt;).&lt;/li&gt;
&lt;li&gt;Subsequent characters can include letters, digits (0-9), underscores, or dollar signs.&lt;/li&gt;
&lt;li&gt;Variable names are case-sensitive.&lt;/li&gt;
&lt;/ul&gt;
&lt;h3 id="scope-of-variables"&gt;Scope of Variables&lt;/h3&gt;
&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;Local Scope&lt;/strong&gt;: Variables declared within a function are accessible only inside that function.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Global Scope&lt;/strong&gt;: Variables declared outside a function or without the &lt;code&gt;var&lt;/code&gt; keyword are accessible throughout the program.&lt;/li&gt;
&lt;/ul&gt;
&lt;hr&gt;
&lt;h2 id="example-variable-declaration-and-control-statements"&gt;Example: Variable Declaration and Control Statements&lt;/h2&gt;
&lt;h3 id="variable-declaration"&gt;Variable Declaration&lt;/h3&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-javascript" data-lang="javascript"&gt;&lt;span class="line"&gt;&lt;span class="ln"&gt;1&lt;/span&gt;&lt;span class="cl"&gt;&lt;span class="kd"&gt;var&lt;/span&gt; &lt;span class="nx"&gt;name&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="s1"&gt;&amp;#39;John&amp;#39;&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="ln"&gt;2&lt;/span&gt;&lt;span class="cl"&gt;&lt;span class="kd"&gt;var&lt;/span&gt; &lt;span class="nx"&gt;age&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;30&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="ln"&gt;3&lt;/span&gt;&lt;span class="cl"&gt;&lt;span class="nx"&gt;console&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;log&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;name&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="s1"&gt;&amp;#39; is &amp;#39;&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="nx"&gt;age&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="s1"&gt;&amp;#39; years old.&amp;#39;&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;h3 id="if-statement"&gt;If Statement&lt;/h3&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-javascript" data-lang="javascript"&gt;&lt;span class="line"&gt;&lt;span class="ln"&gt;1&lt;/span&gt;&lt;span class="cl"&gt;&lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;age&lt;/span&gt; &lt;span class="o"&gt;&amp;gt;&lt;/span&gt; &lt;span class="mi"&gt;18&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="ln"&gt;2&lt;/span&gt;&lt;span class="cl"&gt; &lt;span class="nx"&gt;console&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;log&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s1"&gt;&amp;#39;Adult&amp;#39;&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="ln"&gt;3&lt;/span&gt;&lt;span class="cl"&gt;&lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="k"&gt;else&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="ln"&gt;4&lt;/span&gt;&lt;span class="cl"&gt; &lt;span class="nx"&gt;console&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;log&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s1"&gt;&amp;#39;Minor&amp;#39;&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="ln"&gt;5&lt;/span&gt;&lt;span class="cl"&gt;&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;h3 id="for-loop"&gt;For Loop&lt;/h3&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-javascript" data-lang="javascript"&gt;&lt;span class="line"&gt;&lt;span class="ln"&gt;1&lt;/span&gt;&lt;span class="cl"&gt;&lt;span class="k"&gt;for&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="kd"&gt;var&lt;/span&gt; &lt;span class="nx"&gt;i&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="nx"&gt;i&lt;/span&gt; &lt;span class="o"&gt;&amp;lt;&lt;/span&gt; &lt;span class="mi"&gt;5&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="nx"&gt;i&lt;/span&gt;&lt;span class="o"&gt;++&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="ln"&gt;2&lt;/span&gt;&lt;span class="cl"&gt; &lt;span class="nx"&gt;console&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;log&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s1"&gt;&amp;#39;Iteration &amp;#39;&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="nx"&gt;i&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="ln"&gt;3&lt;/span&gt;&lt;span class="cl"&gt;&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;hr&gt;
&lt;h2 id="conclusion"&gt;Conclusion&lt;/h2&gt;
&lt;p&gt;JavaScript variables allow dynamic data handling with flexible typing and scoping rules.&lt;/p&gt;</description></item></channel></rss>