<?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: Iszyk</title>
    <description>The latest articles on Forem by Iszyk (@iszy).</description>
    <link>https://forem.com/iszy</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%2F3668400%2F7f6f8a90-260a-477d-8b1a-18e12fd4d574.png</url>
      <title>Forem: Iszyk</title>
      <link>https://forem.com/iszy</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://forem.com/feed/iszy"/>
    <language>en</language>
    <item>
      <title>Asynchronous Javascript</title>
      <dc:creator>Iszyk</dc:creator>
      <pubDate>Thu, 02 Apr 2026 09:21:38 +0000</pubDate>
      <link>https://forem.com/iszy/asynchronous-javascript-58mb</link>
      <guid>https://forem.com/iszy/asynchronous-javascript-58mb</guid>
      <description>&lt;p&gt;Asynchronous JavaScript is a way of writing code that allows tasks to run without blocking the rest of your program.&lt;/p&gt;

&lt;p&gt;In simple terms: instead of waiting for a code to finish executing like fetching data from an API, JavaScript continues executing other code and comes back to the result later.&lt;/p&gt;

&lt;p&gt;We basically have two types of operations in javascript, synchronous and asynchronous. The primary difference is that synchronous operations occur sequentially, requiring one task to finish before the next begins, while asynchronous operations allow multiple tasks to run concurrently without waiting, improving efficiency and responsiveness. Synchronous is "blocking" (wait-for-result), while asynchronous is "non-blocking" (continue-to-other-tasks).&lt;/p&gt;

&lt;p&gt;Example of synchronous operation;-&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;
let data = fetchData(); // waits here until done

console.log(data);
console.log("End");
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;&lt;br&gt;
The app pauses until fetchData() finishes.&lt;/p&gt;

&lt;p&gt;Example of asynchronous operation;-&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("Start");

fetchData().then(data =&amp;gt; {
  console.log(data);
});

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

&lt;/div&gt;

&lt;p&gt;&lt;br&gt;
plaintext&lt;br&gt;
The Output;-&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Start
End
(data comes later)
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;&lt;br&gt;
plaintext&lt;/p&gt;

&lt;p&gt;🔹 Common Asynchronous Techniques&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Callbacks&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;A callback is a function passed as an argument to another function, which is then executed (or "called back") inside that outer function to complete a specific task, because functions in JavaScript are First-class Objects, they can be treated like any other variable and passed between functions. &lt;br&gt;
For example,&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;A Simple Synchronous Callback&lt;/strong&gt;&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(name, callback) {
  console.log("Hello, " + name);
  callback(); // Executing the callback function
}

function sayGoodbye() {
  console.log("Goodbye!");
}

// Pass 'sayGoodbye' as a callback to 'greet'
greet("Alice", sayGoodbye);
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;&lt;br&gt;
plaintext&lt;/p&gt;

&lt;p&gt;In this example, the greet function takes a callback as a parameter and executes it immediately after performing its own logic.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Asynchronous Callback&lt;/strong&gt;&lt;br&gt;
Callbacks are essential for asynchronous programming, where a task needs time to complete (like a timer or data fetch) without blocking the rest of the code.&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("Start");

// setTimeout takes an anonymous function as a callback
setTimeout(() =&amp;gt; {
  console.log("This appears after 2 seconds");
}, 2000);

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

&lt;/div&gt;

&lt;p&gt;&lt;br&gt;
plaintext&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Promises&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;In JavaScript, a Promise is an object representing the eventual completion or failure of an asynchronous operation and its resulting value. It serves as a placeholder for a result that is not yet available, allowing you to handle asynchronous code in a cleaner way than traditional callbacks.&lt;br&gt;
    Promises exist in one of three states: pending (ongoing), fulfilled (successful), or rejected (failed). Once fulfilled or rejected, a promise is settled and cannot change state.&lt;/p&gt;

&lt;p&gt;You create a Promise using the new Promise() constructor, which takes an executor function. This function runs immediately and receives two callback arguments provided by the JavaScript engine: resolve and reject.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;const myPromise = new Promise((resolve, reject) =&amp;gt; {
  const success = true; 
  if (success) {
    resolve("Operation Successful!"); // Moves state to Fulfilled
  } else {
    reject("Operation Failed.");      // Moves state to Rejected
  }
});
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;&lt;br&gt;
plaintext&lt;br&gt;
To handle the result of a Promise, you attach handlers using these methods: &lt;br&gt;
.then(): Runs when the promise is fulfilled. It can also take a second argument for rejection.&lt;br&gt;
.catch(): A shorthand for handling errors. It runs if the promise is rejected at any point in the chain.&lt;br&gt;
.finally(): Runs after the promise settles, regardless of whether it succeeded or failed. It is often used for cleanup.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;const myPromise = new Promise((resolve, reject) =&amp;gt; {
  const success = true; 
  if (success) {
    resolve("Operation successful!"); // Marks as fulfilled
  } else {
    reject("Something went wrong.");  // Marks as rejected
  }
});

// Consuming the promise
myPromise
  .then((data) =&amp;gt; console.log(data))    // Runs if resolved
  .catch((err) =&amp;gt; console.error(err))   // Runs if rejected
  .finally(() =&amp;gt; console.log("Done"));  // Always runs

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

&lt;/div&gt;

&lt;p&gt;&lt;br&gt;
plaintext&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Async/Await (Modern &amp;amp; Cleaner)&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;In JavaScript, async and await are keywords used to write asynchronous code that looks and behaves like synchronous code. They are "syntactic sugar" built on top of JavaScript Promises, making complex asynchronous flows easier to read and maintain.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;The Concept&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;async Keyword: Placed before a function declaration to define an asynchronous function.&lt;br&gt;
An async function always returns a Promise.&lt;br&gt;
If the function returns a value, that value is automatically wrapped in a resolved Promise.&lt;/p&gt;

&lt;p&gt;await Keyword: Can only be used inside an async function (or at the top level of a module).&lt;br&gt;
It pauses the execution of the async function until the Promise settles (resolves or rejects).&lt;br&gt;
Once the Promise resolves, it returns the result. If it rejects, it throws an error.&lt;br&gt;
While the function is paused, the JavaScript engine can perform other tasks, making it non-blocking.&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 {
    // Execution pauses here until the fetch promise resolves
    const response = await fetch('https://example.com');

    // Execution pauses again for the .json() promise
    const data = await response.json();

    console.log(data);
  } catch (error) {
    // Standard try/catch handles any errors in the async flow
    console.error("Fetch error:", error);
  }
}

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

&lt;/div&gt;



&lt;p&gt;To fetch data from an API using the Fetch API, the async/await pattern is commonly used.&lt;/p&gt;

</description>
      <category>beginners</category>
      <category>javascript</category>
      <category>programming</category>
      <category>webdev</category>
    </item>
    <item>
      <title>Building a Simple JavaScript Slider: A Code Walkthrough</title>
      <dc:creator>Iszyk</dc:creator>
      <pubDate>Tue, 17 Feb 2026 11:40:15 +0000</pubDate>
      <link>https://forem.com/iszy/building-a-simple-javascript-slider-a-code-walkthrough-2ae1</link>
      <guid>https://forem.com/iszy/building-a-simple-javascript-slider-a-code-walkthrough-2ae1</guid>
      <description>&lt;p&gt;Image sliders are one of the most widely used UI components in modern web development. From product showcases and portfolio galleries to testimonials and hero banners, sliders allow multiple pieces of content to occupy the same space while keeping the interface clean and interactive. First of all, what is a slider? A slider is a UI component that displays one slide at a time, it allows navigation between slides, it moves content horizontally (most common) or vertically and lastly it uses animation for smooth transitions. A slider typically displays one item at a time and lets users navigate between items using arrows, dots, or swipe gestures. &lt;br&gt;
        The images are placed horizontally inside a fixed-width container but only one slide is visible because the container hides the overflow as shown below.&lt;br&gt;
+----------------------------------+&lt;br&gt;
|          Viewport Window         |&lt;br&gt;
|  [ Slide 1 ]                     |&lt;br&gt;
+----------------------------------+&lt;br&gt;
When we click "Next", we shift the entire row left, likewise when we click "Previous", we shift the entire right. By this way, we allow the next image that was hidden to be displayed while the previous goes hidden. &lt;br&gt;
   When we want to build an image slider, we start with the HTML document by creating the div container first with a class of slider, the left and right arrows are enclosed in a button element with a class of slider_&lt;em&gt;btn slider&lt;/em&gt;_btn--left in the HTML. Then we create the img element with the images we want, and also with a class of slides as it is shown below.&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;div class="slider"&amp;gt;
                    &amp;lt;img src="../images/image-product-1.jpg" alt="Slide 1" class="slide"&amp;gt;
                    &amp;lt;img src="../images/image-product-2.jpg" alt="Slide 2" class="slide"&amp;gt;
                    &amp;lt;img src="../images/image-product-3.jpg" alt="Slide 3" class="slide"&amp;gt;
                    &amp;lt;img src="../images/image-product-4.jpg" alt="Slide 4" class="slide"&amp;gt;
                    &amp;lt;button class="slider__btn slider__btn--left"&amp;gt;&amp;amp;larr;&amp;lt;/button&amp;gt;
                    &amp;lt;button class="slider__btn slider__btn--right"&amp;gt;&amp;amp;rarr;&amp;lt;/button&amp;gt;
            &amp;lt;/div&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The next step is the styling which is done in the css file section. The styling shown below is in 375px, it is shown in mobile view. It gives basic layout, the hiding and showing behavior for slides.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;.slider{
    display: flex;
    gap: 10px;
    align-items: center;
    justify-content: center;
}

.slides {
    display: flex;
    width: 100%;
    height: auto;
}

.slider__btn--left {
    left: 5px;
}

.slider__btn--right {
    right: 5px;
}

.slider__btn {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    background-color: white;
    border: none;
    width: 45px;
    height: 45px;
    border-radius: 50%;
    cursor: pointer;
    font-size: 18px;
    color: hsl(26, 100%, 55%);
    font-weight: 700;
    z-index: 10;
} 
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The last step is implementing the javascript logic. The logic is to make sure that when the button is clicked, it performs a function which is showing the correct slide in this context.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;let currentMobileSlide = 0;
const mobileSlides = document.querySelectorAll('.slider .slide');
const mobileLeftBtn = document.querySelector('.slider__btn--left');
const mobileRightBtn = document.querySelector('.slider__btn--right');

unction showMobileSlide(index) {
    if (!mobileSlides || mobileSlides.length === 0) return;
    mobileSlides.forEach((slide, i) =&amp;gt; {
        slide.style.display = (i === index) ? 'block' : 'none';
        slide.classList.toggle('active', i === index);
    });
}

if (mobileLeftBtn) {
    mobileLeftBtn.addEventListener('click', () =&amp;gt; {
        currentMobileSlide = (currentMobileSlide === 0) ? mobileSlides.length - 1 : currentMobileSlide - 1;
        showMobileSlide(currentMobileSlide);
    });
}

if (mobileRightBtn) {
    mobileRightBtn.addEventListener('click', () =&amp;gt; {
        currentMobileSlide = (currentMobileSlide === mobileSlides.length - 1) ? 0 : currentMobileSlide + 1;
        showMobileSlide(currentMobileSlide);
    });
}

// Initialize mobile slider
showMobileSlide(currentMobileSlide);
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;In conclusion, slider is simple and lightweight, ideal for portfolios or landing pages. It can also be enhanced by adding autoplay, swipe gestures and/or transition effects.&lt;/p&gt;

</description>
      <category>programming</category>
      <category>javascript</category>
      <category>beginners</category>
      <category>frontend</category>
    </item>
    <item>
      <title>JavaScript and Event listeners</title>
      <dc:creator>Iszyk</dc:creator>
      <pubDate>Mon, 22 Dec 2025 11:06:50 +0000</pubDate>
      <link>https://forem.com/iszy/javascript-and-event-listeners-2901</link>
      <guid>https://forem.com/iszy/javascript-and-event-listeners-2901</guid>
      <description>&lt;p&gt;This is my first article and I want to use the medium to talk about event listeners in JavaScript. Event listeners is like the heart of JavaScript, without event listeners, most web pages will be static and non-interactive. Event listeners is one of the most important features that JavaScript uses to create interactivity in a web page. &lt;br&gt;
      Let’s work through what event listener is, how they work, their importance and how to use them respectively. &lt;br&gt;
       An event is any action that happens in the web page like clicking a button, typing in a given space, dragging and dropping a file or an item, submitting a form, etc …. when these actions occur, JavaScript can detect and react to them. &lt;br&gt;
        An event listener is a JavaScript function that waits and listen for an event to occur and then run the functions is that event. The most common way to handle events in JavaScript is through the addEventListener () method. &lt;br&gt;
       Types of events in JavaScript are:-&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;The click event &lt;/li&gt;
&lt;li&gt;Change&lt;/li&gt;
&lt;li&gt;Input &lt;/li&gt;
&lt;li&gt;Mousemove &lt;/li&gt;
&lt;li&gt;Keypress like the esc key&lt;/li&gt;
&lt;li&gt;Double click and so on
Another key point to note in event listener is the event.preventDefault(). The preventDefault() method is most useful in situations where the default behavior of an HTML element interferes with the desired user experience. For example when we are trying to submit an empty form using HTML, the whole page refreshes, but the preventDefault() method is used to stop pages from refreshing.
 In conclusion, mastering event listeners is essential for any JavaScript developer —and as you continue building projects, you’ll see them everywhere and how important they are in building web pages. &lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;In summary, events are the reason why you find a website or an application interesting to use. Events are the interactivity that occurs on a website when you click a button, press a keyboard, or mouse over code and the state changes when you use the window object to resize your browser; Events are everything and more in JavaScript. Events are the major reason between a static website and a dynamic one. A static website or application is one just as the name implies, static, uneventful and dry. Static websites are just there to display information about a product, organization, expertise etc. A dynamic application on the other hand shows more than just display information. They collect data from users, and allow users to send information about their requests to the organization or give a review about a product; they are dynamic.&lt;/p&gt;

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