JavaScript inArray Check if value exists

Today, We want to share with you JavaScript inArray Check if value exists.In this post we will show you javascript check if value exists in array of objects, hear for Check if value exists in Array jQuery and JavaScript we will give you demo and example for implement.In this post, we will learn about Determine whether an array contains a value with an example.

JavaScript inArray Check if value exists

There are the Following The simple About JavaScript inArray Check if value exists Full Information With Example and source code.

As I will cover this Post with live Working example to develop javascript check if value exists in array of objects, so the some javascript find index of object in array for this example is following below.

using JavaScript Custom Function

JavaScript Completed Code


var players_arr = ['Jaydeep','Ankit','Ramji','Jaydeep','Mayur','Hitesh'];
 
function checkValue(value,arr){
  var status = 'players are Not exist';
 
  for(var i=0; i<arr.length; i++){
    var name = arr[i];
    if(name == value){
      status = 'Good Luck, Exist';
      break;
    }
  }

  return status;
}
console.log('status : ' + checkValue('Jaydeep', players_arr) );
console.log('status : ' + checkValue('Krunal', players_arr) );

JavaScript Array indexOf() Method

Using Array.indexOf()

var players_arr = ['Gondaliya','jaydeep','Dipak','Rakesh','Bachu'];
var text = "Gondaliya Bipin";

//Players Search in Array
console.log( 'Array Index : ' + players_arr.indexOf('Dipak') );
console.log( 'Array Index : ' + players_arr.indexOf('Hiten') );

//Players Search in String
console.log( 'Array Index : ' + text.indexOf('a') );


using jQuery.inArray()

var players_arr = ['Gondaliya','Jaydeep','raj','mayur','ketan'];
var text = "jaydeep patel";
//Players Searching in Array
console.log( 'Array Index : ' + jQuery.inArray('raj', players_arr) );
console.log( 'Array Index : ' + jQuery.inArray('ankit', players_arr ));
 
//Players Searching in String variable
console.log( 'Array Index : ' + jQuery.inArray( "e", text ));


Angular 6 CRUD Operations Application Tutorials

Read :

Read Also:  datepicker change date format dynamically using jquery

Summary

You can also read about AngularJS, ASP.NET, VueJs, PHP.

I hope you get an idea about JavaScript inArray Check if value exists.
I would like to have feedback on my Pakainfo.com blog.
Your valuable feedback, question, or comments about this article are always welcome.
If you enjoyed and liked this post, don’t forget to share.