Find an item in an array with the ‘findIndex’ method in JavaScript.

Photo by Gratisography from Pexels
arr.findIndex(callback( element, index, array ) ,thisArg)
  • callback function → A function to execute on each value in the array until the function returns true, indicating that the satisfying element was found.
  • thisArg → Optional object to use as this when executing callback.
  • element → current processing element
  • index (Optional)→ index of the element…


Learn how to improve the performance of rendering in canvas by using OffscreenCanvas

Photo by Snapwire from Pexels

The OffscreenCanvas interface allows canvas rendering contexts (2D and WebGL) to be used in Workers. It increases parallelism in the web, leading to improved performance on multi-core systems.

Using OffscreenCanvas we can render a canvas in the worker thread so that the main thread will be undisturbed so that our web app will work smoothly.

The support of OffscreenCanvas across the browser can be found here CanIUse.

There are two ways we can use OffscreenCanvas

  1. Creating an OffscreenCanvas from existing canvas
  2. Creating an OffscreenCanvas manually and render…


Learn how to use preventExtensions to stop adding new properties to a JavaScript Object

Photo by Dan-Cristian Pădureț on Unsplash

The Object.preventExtensions() method prevents new properties from added to an object.

  • preventExtensions method returns the object being made non-extensible.
  • There is no way to make an object extensible again once it has been made non-extensible.
  • To check if the object is non-extensible we can use Object.isExtensible()
  • preventExtensions()method only prevents addition of own properties. …


Understanding the Split Method in JavaScript

Image taken here.

The split method spilt the string into array of substring based on the pattern provided.

Example

let numbersStr = "1,2,3,4,5";let numArray = numbersStr.split(",");console.log(numArray); // ["1","2","3","4","5"]

If we don’t pass any pattern then the entire string will be pushed to an…


Learn how to make requests using XMLHttpRequests

summary of key XMLHttpRequest commands covered in this article
summary of key XMLHttpRequest commands covered in this article
Image source: Author

What Is XMLHttpRequest (XHR)?

  • XMLHttpRequest is an in-built JavaScript object that is used to transfer data between a server and a client without refreshing the whole page.
  • Bu using XHR we can update the page based on the user action.
  • For example, an infinite news feed. (Once the user scrolls down to the end of the page, we make a request to fetch the next article and append the data to the page).
  • Using XHR, we can make both synchronous and asynchronous requests.

Steps to Make a Request Using XMLHttpRequest

  • Create an XMLHttpRequest object.
  • Configure the object with request details .
  • Send request.

1. Create a XMLHttpRequest object

let request = new XMLHttpRequest();

2. Configure the object with request details

To configure the…


Learn to check if the primitive value or object present in an array in JavaScript

Photo by Deva Darshan on Unsplash

Checking if a primitive value present in an array

You can use

  • indexOf
  • includes
  • Using normal For loop
var num = [1,2,3,4,5];

indexOf

The indexOf() method returns the first index of the element in the array, if the searching element is not present in the array then it returns -1 .

num.indexOf(3); // 2num.indexOf(6); //-1num.indexOf('3'); // -1
var array = [NaN];array.indexOf(NaN); // -1


Requesting donation for my Badminton Training.

Image by Vladislav

Hello Reader, My name is Jagathish Saravanan, I am from India. I am currently working as a Web developer , I love my Job , but once I started playing Badminton , I started loving Badminton more that anything , So I have decided to switch my carrer to Badminton, It is hard to manage my training expense , so I started writing Blog in Medium . But medium partner program is not supported in India. So I am requesting you to donate some amount .

You can donate me in PayPal :

https://paypal.me/jagathishSaravanan?locale.x=en_GB

Google pay: 8015851838.

Thank you so much for your time


Learn how to generate ASCII art from the image using Python.

Generated in Python

Steps to convert image to ASCII character

  • Load an image
  • Resize Image
  • Convert image to GreyScale
  • Convert GreyScale data of each pixel into respective ASCII character

Loading an Image using PIL image Library

To load the image we will be using PIL library.

import PIL.Image

def main():
path = input("Enter the path to the image fiel : \n")
try:
image = PIL.Image.open(path)
except:
print(path, "Unable to find image ");

Javascript Jeep🚙💨

Articles related to JavaScript.

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store