Skip to main content
12253 votes
51 answers
13.6m views

How do I remove a specific value from an array? Something like: array.remove(value); Constraints: I have to use core JavaScript. Frameworks are not allowed.
Walker's user avatar
  • 136k
5809 votes
41 answers
5.5m views

How can I loop through all the entries in an array using JavaScript?
Dante1986's user avatar
  • 60.3k
5009 votes
64 answers
3.7m views

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++...
brad's user avatar
  • 75.9k
4351 votes
34 answers
3.7m views

I am looking for a JavaScript array insert method, in the style of: arr.insert(index, item) It should preferably be in jQuery, but any JavaScript implementation will do at this point.
tags2k's user avatar
  • 84.7k
4231 votes
61 answers
3.5m views

I have an array of JavaScript objects: var objs = [ { first_nom: 'Laszlo', last_nom: 'Jamf' }, { first_nom: 'Pig', last_nom: 'Bodine' }, { first_nom: 'Pirate', last_nom: '...
Tyrone Slothrop's user avatar
4136 votes
33 answers
3.8m views

How do I check if a particular key exists in a JavaScript object or array? If a key doesn't exist, and I try to access it, will it return false? Or throw an error?
Adam Ernst's user avatar
  • 54.3k
4129 votes
42 answers
1.9m views

Element[] array = {new Element(1), new Element(2), new Element(3)}; How do I convert the above variable of type Element[] into a variable of type ArrayList<Element>? ArrayList<Element> ...
Ron Tuffin's user avatar
  • 54.8k
4096 votes
46 answers
5.6m views

In Java, you can use a for loop to traverse objects in an array as follows: String[] myStringArray = {"Hello", "World"}; for (String s : myStringArray) { // Do something } Can ...
Mark Szymanski's user avatar
3360 votes
51 answers
2.1m views

I'm trying to write a function that either accepts a list of strings, or a single string. If it's a string, then I want to convert it to an array with just the one item so I can loop over it without ...
mpen's user avatar
  • 285k
3111 votes
26 answers
3.9m views

Is there an easy way to delete an element from an array using PHP, such that foreach ($array) no longer includes that element? I thought that setting it to null would do it, but apparently it does ...
Ben's user avatar
  • 69k
2924 votes
94 answers
3.7m views

I have an array of numbers that I need to make sure are unique. I found the code snippet below on the Internet, and it works great until the array has a zero in it. I found this other script here on ...
Mottie's user avatar
  • 86.8k
2889 votes
30 answers
5.5m views

How do I append an object (such as a string or number) to an array in JavaScript?
2760 votes
33 answers
2.9m views

I have a String[] with values like so: public static final String[] VALUES = new String[] {"AB","BC","CD","AE"}; Given String s, is there a good way of testing whether VALUES contains s?
Mike Sickler's user avatar
  • 34.7k
2578 votes
31 answers
6.0m views

How do I declare and initialize an array in Java?
bestattendance's user avatar

15 30 50 per page
1
2 3 4 5
27871