Check if value exists in Array – jQuery and JavaScript

In this tutorial, I show how you can check whether an Array already contains a specific value or not using Javascript and jQuery.

This requires within the program in some cases like –

  • Stop new value from insert if it already exists in an Array.
  • Execute script when the Array contains a particular value.
  • etc.

If you are familiar with PHP, where you can use the in_array() function to search value in the Array, and it returns the Boolean value ( TRUE or FALSE ).

There are inbuilt methods in jQuery and JavaScript that return the index position of the value which you can use for the search.

Check if value exists in Array – jQuery and JavaScript

Read more

How to Detect Browser Window is Active or not – JavaScript

Sometimes you may want to take more control over your user Browser when he/she opens your website in a Browser Window.

For example – you want to know when the user closes the Browser Tab and execute your code.

If you want to know how much time the user active on your website, in this case, you can use JavaScript. Using that you only enabled the timer when the user is an active tab on your website.

Or you want to run the Animation only when the user is active otherwise stop it.

This kind of functionality you have seen on websites or PTC sites that provide ads viewing to the users. They only count the ads view when the user is active on their website until a given time otherwise they cancel the view after the specific time.

In this tutorial, I show how you can use JavaScript to detect whether Browser Tab Window is active or not.

How to Detect Browser Window is Active or not - JavaScript

Read more

Deleting Values from JavaScript Arrays: Methods and Examples

In JavaScript, dele­ting values from an array is a common task. There may be­ various scenarios where the­ removal of specific values be­comes necessary within a program. Fortunate­ly, JavaScript provides several built-in functions spe­cifically designed to efficie­ntly handle such situations.

When it comes to deleting values from an array, some of these inbuilt functions automatically rearrange the array index after deletion, while others solely remove the value without reordering the index. Understanding and utilizing these functions appropriately can significantly enhance your JavaScript coding skills.

In this tutorial, I will show you how to use these functions to efficiently delete values from an array, while maintaining the array’s integrity.

Let’s delve into JavaScript and learn how to delete values from an array using inbuilt functions.

Deleting Values from JavaScript Arrays: Methods and Examples

 

Read more