<?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: Anish Khadtare</title>
    <description>The latest articles on Forem by Anish Khadtare (@anish_khadtare).</description>
    <link>https://forem.com/anish_khadtare</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%2F1185716%2Fd3c0a500-1e2e-4772-8bfc-ecc72fbf9d3d.png</url>
      <title>Forem: Anish Khadtare</title>
      <link>https://forem.com/anish_khadtare</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://forem.com/feed/anish_khadtare"/>
    <language>en</language>
    <item>
      <title>Learn JavaScript Basics to Advance</title>
      <dc:creator>Anish Khadtare</dc:creator>
      <pubDate>Sun, 15 Oct 2023 18:10:24 +0000</pubDate>
      <link>https://forem.com/anish_khadtare/learn-javascript-basics-to-advance-1inn</link>
      <guid>https://forem.com/anish_khadtare/learn-javascript-basics-to-advance-1inn</guid>
      <description>&lt;p&gt;JavaScript is a versatile and dynamic programming language that has become a fundamental tool in modern web development. Initially designed to add interactivity to web pages, JavaScript has evolved to become a robust language used for creating complex applications and running code on various platforms. Whether you want to enhance user interfaces, build server-side applications, or develop mobile applications, JavaScript provides the foundation for all these endeavors.&lt;/p&gt;

&lt;p&gt;We would start from the basics and explore the advanced topics too. Let's get started.&lt;/p&gt;

&lt;h2&gt;
  
  
  BASICS
&lt;/h2&gt;

&lt;h2&gt;
  
  
  Variables in JavaScript
&lt;/h2&gt;

&lt;p&gt;In JavaScript, three variables are used to declare variables var, let, and const.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;var car = 'Tata Nexon';
let colour = 'Blue';
const carId = 509;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;var is functionally scoped when declared inside a function and global scope when declared outside a function. The value of the variable declared by var can be changed and re-declared.&lt;/p&gt;

&lt;p&gt;A block is a piece of code inside {}. Anything written inside the curly braces is a block. A variable declared in a block with let is only available for use within that block. So the value of that variable can not be accessed outside the block. The value of let can be changed but not re-declared.&lt;/p&gt;

&lt;p&gt;const is used to declare some constant value that will not be changed at any time. The value of the const variable can not be changed nor re-declared.&lt;/p&gt;

&lt;h2&gt;
  
  
  Data Types in JavaScript
&lt;/h2&gt;

&lt;p&gt;JavaScript has several data types, including numbers, strings, booleans, arrays, and objects.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;let age = 20;
let language = 'JavaScript';
let flag = true;
let array = [10,20,30,40,50];
let code = {lines : 100, errors : 0, topic : 'blog'};
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Arrays in JavaScript
&lt;/h2&gt;

&lt;p&gt;Arrays consist of square brackets and items that are separated by commas.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;let fruits  = ["Mango","Apples","Oranges","Guava"];
console.log(fruits);

let random = [52,"laptop","grapes",67];
console.log(random);

let number = [52,83,12,64,67];
console.log(number);

/*Finding length of array*/
console.log(fruits.lenght);

/*Accessing a particular element from an array*/
console.log(fruits[2]);

/*Adding items to end of array */
random.push(16);

/*Removing items from end of array */
random.pop(16);

/*Adding items to start of array */
random.unshift(16);

/*Removing items from start of array */
random.shift(16);

/* Accessing all the elements of array using map */
/* Here for every num in array number each num is doubled */

let doubled = number.map((num) =&amp;gt; num*2);
console.log(doubled);

/* Filtering the array */
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Objects in JavaScript
&lt;/h2&gt;

&lt;p&gt;An object is a collection of several properties and functions that belong to a particular object.&lt;/p&gt;

&lt;p&gt;The object is made in the key-value pair format.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;const car = {
    color:"white",
    brand:"Tata",
    price:500000,
    information: function(){
        console.log(`The car is of colour ${color}`);
};
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Here the car is the object having a color, brand, price, information are keys.&lt;/p&gt;

&lt;h2&gt;
  
  
  Operators in JavaScript
&lt;/h2&gt;

&lt;p&gt;JavaScript supports arithmetic, assignment, comparison, logical, and other operators.&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 = 15 + 5; // Addition
let y = 16 - 5; // Subtraction
let z = 6 * 5; // Multiplication
let w = 20 / 5; // Division
let a = 50 % 5; // Modulo

let b = 10;
b += 15; // b is now 15 (addition assignment)

let isEqual = (50 === 15); // Comparison (equal to)

let result = (x &amp;gt; 0 &amp;amp;&amp;amp; y &amp;lt; 5); // Logical (AND)
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Control Flow in JavaScript
&lt;/h2&gt;

&lt;p&gt;JavaScript provides control flow statements like if-else, for loops, and while loops.&lt;br&gt;
&lt;/p&gt;

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

if (num &amp;gt; 0) {                     /* Checks the condition */
  console.log('Number is positive');
} 
else if (num &amp;lt; 0) {                /* If the first condition not statisfied */
  console.log('Number is negative');
}
else {                             /* If no condition are statisfied */
  console.log('Number is zero');
}

for (let i = 0; i &amp;lt; 5; i++) {      /* For Loop */
  console.log(i);
}

let i = 0;                         /* While loop */
while (i &amp;lt; 5) {
  console.log(i);
  i++;
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Functions in JavaScript
&lt;/h2&gt;

&lt;p&gt;JavaScript functions allow you to group code into reusable blocks.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;function carProperties(colour,price){
    console.log("Car is of " + colour + " colour and its price is " + price + " Rs ");
}
carProperties("white",500000);

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

&lt;/div&gt;



&lt;p&gt;Here carProperties is the function name having parameters color and price of the car. The value of these parameters is given in the function call as white and 500000.&lt;/p&gt;

&lt;p&gt;Now this same function can be written in a simpler way or an optimized way which is the ARROW Function.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;const carProperties = (colour,price) =&amp;gt; {
    console.log("Car is of " + colour + " colour and its price is " + price + " Rs ");
}
carProperties("white",500000);
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Intermediate
&lt;/h2&gt;

&lt;h2&gt;
  
  
  this keyword
&lt;/h2&gt;

&lt;p&gt;this keyword is a special type of keyword that refers to the context in which a function is executed. It allows to access properties and methods within the current execution context.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;const cars = {
    colour : "blue",
    price  : 500000,
    brand  : "Tata Nexon", 
    info   : function(){
        return this.brand + " " + this.colour + " " + this.price;
    } 
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Here this keyword refers to the parent object cars.&lt;/p&gt;

&lt;p&gt;When this keyword is used alone it refers to a global 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 value = this;
console.log(value);
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Async Functions in JavaScript
&lt;/h2&gt;

&lt;p&gt;Async functions are a feature in JavaScript that allows you to write asynchronous code in a more synchronous-like manner. They are defined using the async keyword, and they always return a promise. The use of async functions is closely tied to the await keyword, which can be used to pause the execution of the function until a promise is resolved. Async Functions are used while fetching data from APIs.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;async function fetchData(){
    try{
        const response = await fetch("https://api.info/cars"); /* Your API */
        const data = await response.json();
        console.log(data);
    }
    catch(error){
        console.log("ERROR : ",error);
    }
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The function fetchData is an asynchronous function and error handling is performed using try and catch. The data is fetched from the API using the fetch keyword and stored in response. The await keyword is used to pause the execution until a promise is resolved. This response is then parsed in the response body as JSON.&lt;/p&gt;

&lt;h2&gt;
  
  
  CallBack functions in JavaScript
&lt;/h2&gt;

&lt;p&gt;The callback function is a function that is passed within a function as a parameter and is invoked 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;function fetchData(callback) {
  setTimeout(function() {
    const data = { id: 1, name: 'John Doe' };
    callback(null, data);
  }, 2000);
}

function processResult(error, data) {
  if (error) {
    console.log('Error:', error);
  } else {
    console.log('Data:', data);
  }
}

fetchData(processResult);
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Advanced
&lt;/h2&gt;

&lt;h2&gt;
  
  
  getElementById in JavaScript
&lt;/h2&gt;

&lt;p&gt;The getElementById is used to manipulate the HTML elements on a web page by using the unique ID given to them.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;&amp;lt;html&amp;gt;
    &amp;lt;head&amp;gt; &amp;lt;/head&amp;gt;
    &amp;lt;body&amp;gt;
        &amp;lt;p id="score"&amp;gt;0&amp;lt;/p&amp;gt;
    &amp;lt;/body&amp;gt;
    &amp;lt;script src="script.js"&amp;gt;&amp;lt;/script&amp;gt;
&amp;lt;/html&amp;gt;

let value = 10;
let score = document.getElementById("score");
/* Now for changing the contents */
score.innerText = value;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;So here the HTML element is been accessed using the ID score and then manipulated using innerText to change the value of the score to 10 on the web page.&lt;/p&gt;

&lt;p&gt;Similarly for accessing elements by classes, we can use getElementsByClassName.&lt;/p&gt;

&lt;p&gt;Accessing elements can also be done using querySelector("#id") and querySelectorAll(".className").&lt;/p&gt;

&lt;h2&gt;
  
  
  addEventListner in JavaScript
&lt;/h2&gt;

&lt;p&gt;In JavaScript, the addEventListners method is used to attach event handlers to HTML elements. This method allows you to define a function that will be executed when a specific event occurs on the target element.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;const btn = document.getElementById("button");
btn.addEventListner("click",()=&amp;gt; {
    console.log("clicked Button");
})
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  forEach in JavaScript
&lt;/h2&gt;

&lt;p&gt;When we want to perform the same action many times, instead of using it every time we can perform the same action a single time for different objects.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;&amp;lt;html&amp;gt;
    &amp;lt;head&amp;gt; &amp;lt;/head&amp;gt;
    &amp;lt;body&amp;gt;
        &amp;lt;p id="count"&amp;gt;0&amp;lt;/p&amp;gt;
        &amp;lt;button class="btn btnInc"&amp;gt;Increase&amp;lt;/button&amp;gt;
        &amp;lt;button class="btn btnRes"&amp;gt;Reset&amp;lt;/button&amp;gt;
        &amp;lt;button class="btn btnDec"&amp;gt;Decrease&amp;lt;/button&amp;gt;
    &amp;lt;/body&amp;gt;
    &amp;lt;script src="script.js"&amp;gt;&amp;lt;/script&amp;gt;
&amp;lt;/html&amp;gt;

const btns = document.querySelectorAll(".btn");
let count = document.getElementById("count");
let value = 0;
btns.forEach((btn) =&amp;gt; {
    if(btn.currentTarget.classList.contains("btnInc")){
        value++;
    }
    else if(btn.currentTarget.classList.contains("btnDec")){
        value--;
    }
    else{
        value = 0;
    }
})
count.innerText = value;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  map in Javascript
&lt;/h2&gt;

&lt;p&gt;In JavaScript, the map method is used to transform the elements of an array by applying a given function to each element and creating a new array with the results. It is a common functional programming method that is often used for tasks like data manipulation, filtering, or extracting specific values from 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;const numbers = [1, 2, 3, 4, 5];

// Doubling each number using map
const doubledNumbers = numbers.map((number) =&amp;gt; {
    return number * 2;
});

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

&lt;/div&gt;



&lt;h2&gt;
  
  
  filter in javaScript
&lt;/h2&gt;

&lt;p&gt;In JavaScript, the filter method is used to create a new array containing all the elements from an existing array that meet a specified condition. It's a convenient way to filter out elements that you don't need from 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;
const numbers = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10];

// Filtering even numbers using filter
const evenNumbers = numbers.filter((number) =&amp;gt; {
    return number % 2 === 0;
});

console.log(evenNumbers); // Output: [2, 4, 6, 8, 10]
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



</description>
      <category>javascript</category>
      <category>development</category>
      <category>frontend</category>
      <category>programming</category>
    </item>
    <item>
      <title>Which programming language should I start with Python / Java / C++?</title>
      <dc:creator>Anish Khadtare</dc:creator>
      <pubDate>Sun, 15 Oct 2023 17:48:38 +0000</pubDate>
      <link>https://forem.com/anish_khadtare/which-programming-language-should-i-start-with-python-java-c-2fj1</link>
      <guid>https://forem.com/anish_khadtare/which-programming-language-should-i-start-with-python-java-c-2fj1</guid>
      <description>&lt;p&gt;No language is better than any other language it is based on one's use case which programming one should start with.&lt;/p&gt;

&lt;h2&gt;
  
  
  Python
&lt;/h2&gt;

&lt;p&gt;If one is new to programming and if he wants to start his programming journey he should start it with Python language. As Python is easy to use and its syntax is like the English language it will be easy to master it.&lt;/p&gt;

&lt;p&gt;Python has tons of different libraries like Numpy, Pandas, TensorFlow, PyTorch etc which are heavily used in Data Science, Machine Learning, and AI.&lt;/p&gt;

&lt;p&gt;So if one wants to go into these fields or wants to become a Python developer then Python would be the best language to start with.&lt;/p&gt;

&lt;p&gt;But if one has to go for competitive programming then Python may not be a great language as it is considered as a slow language.&lt;/p&gt;

&lt;h2&gt;
  
  
  C++
&lt;/h2&gt;

&lt;p&gt;If one wants to go into core competitive programming then C++ would be the best language to be selected as it is faster than many other languages. As C++ is a core language it is easier to move from C++ to Python but it would be more challenging to do vice versa.&lt;/p&gt;

&lt;p&gt;In C++ one has to implement all the things from scratch as compared to Python but it makes our base stronger.&lt;/p&gt;

&lt;p&gt;For a newbie, C++ may be more challenging to start with due to its syntax but in the longer run it is going to be easier to switch to any language.&lt;/p&gt;

&lt;h2&gt;
  
  
  Java
&lt;/h2&gt;

&lt;p&gt;Java act as a mediator between C++ and Python. Java can be used even for competitive programming as well as for projects in Android development and Web development.&lt;/p&gt;

&lt;p&gt;The demand for Java is also increasing day by day and mastering it also also easy as compared to C++. The concepts like pointers get reduced from Java which we would have to learn in C++.&lt;/p&gt;

&lt;p&gt;Conclusion&lt;/p&gt;

&lt;p&gt;So to conclude no language is better than any other language it's just based on the use case one should select it and start his programming.&lt;/p&gt;

&lt;p&gt;As it is important to choose any one language and master it.&lt;/p&gt;

</description>
      <category>python</category>
      <category>java</category>
      <category>programming</category>
      <category>datastructures</category>
    </item>
  </channel>
</rss>
