Splice from multi-dimensional array?
Hi all
I have multi-dimensional array - 3 arrays inside another array.
I want to splice from one of the arrays and replace the removed item.
How can I splice from a multi-dimensional array?
Code:<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8"/> <title>Splice from multi-dimensional array</title> </head> <body> <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js"></script> <script type="text/javascript"> var colors_arr = new Array(); var numbers_arr = new Array(); var names_arr = new Array(); var all_arr = new Array(); // colors_arr.push('red','green','blue','black','yellow'); numbers_arr.push('one','two','three','four','five'); names_arr.push('Chris','John','Jack','Sarah','Jane'); // all_arr.push(colors_arr); all_arr.push(numbers_arr); all_arr.push(names_arr); // alert(all_arr[2]); var arr = 2; var item = 2; var replace = 'Jill'; all_arr.splice([arr][item],1, replace); alert(all_arr[2]); </script> </body> </html>



Reply With Quote
Bookmarks