Linked Questions
12 questions linked to/from How to check if a string array contains one string in JavaScript?
5002
votes
63
answers
3.7m
views
How do I check if an array includes a value in JavaScript?
What is the most concise and efficient way to find out if a JavaScript array contains a value?
This is the only way I know to do it:
function contains(a, obj) {
for (var i = 0; i < a.length; i++...
3
votes
3
answers
5k
views
javascript - check if string is in a array without case sensitive [duplicate]
I want to make a filter. Where if you input a word that is in the 'blacklist' it will tell something. I've got all the code but have a problem.
JS:
input = document.getElementById("input").value;
...
2
votes
1
answer
222
views
check if a string is part of an array - javascript [duplicate]
I want to be able to see if "megan" is a part of the array people. Though, i can only do this by using people[2].
Here is my code:
var people = new Array("jack","ian");
document.write(people[0]);
...
840
votes
8
answers
1.2m
views
Best way to find if an item is in a JavaScript array? [duplicate]
What is the best way to find if an object is in an array?
This is the best way I know:
function include(arr, obj) {
for (var i = 0; i < arr.length; i++) {
if (arr[i] == obj) return ...
286
votes
21
answers
373k
views
JavaScript equivalent of PHP's in_array()
Is there a way in JavaScript to compare values from one array and see if it is in another array?
Similar to PHP's in_array function?
7
votes
3
answers
67k
views
How to check if the JSON Object array contains the value defined in an array or not?
I have the following JSON data.
categories = [
{catValue:1, catName: 'Arts, crafts, and collectibles'},
{catValue:2, catName: 'Baby'},
{catValue:3, catName: 'Beauty and fragrances'},
{...
0
votes
4
answers
40k
views
How to check if the id exists in the array of ids javascript
I have an object like:
item: {
b: null
c: "asd"
i: 10
q: 10
s: Array [237,241]}
Also I have an array of ids:
var ids = [237, 238, 239, 240, 242, 243...]
I dont know how to check ...
3
votes
3
answers
21k
views
How to match a variable value against an array of values in Javascript?
I have an array of values with names:
names = ['Jim', 'Jack', 'Fred']
I have also received a value from a function, which is a name in string form, such as:
returnedValue = 'Jim'
How can I run the ...
-1
votes
5
answers
708
views
JavaScript - Detect string from array in input and output the string
I want to detect if a user types one of the strings of my list and then output in what string the user typed in the console.
HTML
<input id="input"></input>
JS
window.onload = function()...
3
votes
2
answers
123
views
Javascript - indexOf not so specific
There is a way to lower the sensibility of the indexOf?
Like this
var arr = ["Hello", "stackoverflow"]
var idx = arr.indexOf("stack")
And get idx = 1 instead of idx = -1
3
votes
3
answers
143
views
match a string using all the strings in array
Hello, I'm trying to make a simple matching game in javascript.
If the the user inserts the text president goes crazy in any way that contains every strings in word_tmp, then the word_tmp becomes ...
-2
votes
2
answers
113
views
How can I check if the user input with the database information?
I have a JavaScript programme that randomly selects an image of an object from the database and display that image to the user. The image is saved with the object name (i.e. apple.gif)
I am using the ...