var items = Array(523,3452,334,31,...5346);
Each item of this array is some number.
How do I replace some number in with array with a new one?
For example, we want to replace 3452 with 1010, how would we do this?
Each item of this array is some number. How do I replace some number in with array with a new one? For example, we want to replace 3452 with 1010, how would we do this? |
|||||||||
|
Also it is recommend you not use the constructor method to initialize your arrays. Instead, use the literal syntax:
You can also use the
Sometimes I even like to write a
|
|||||||||
|
Single-known-instance solution:
|
||||
|
Use indexOf to find an element.
|
|||||
|
Easily accomplished with a
|
|||||||||||||
|
The
Of course, that creates a new array. If you want to do it in place, use
|
|||||
|
you can edit any number of the list using indexes for example : items [0]=5; items[5]=100; |
|||
|
The easiest way is to use some libraries like underscorejs and map method.
|
|||||
|