javascript. remove items in a nested array -
i practicing - getting fluent arrays. created 2 arrays:
var arr var arr2 i pushed them.
spliced them.
merged them.
removed them.
my objective remove first 2 indexes (carl , erich) arr
put them array in first 2 index positions.
can see, somehow inserted them 'nested' array.
i have tried searching documentation have not found best practice this.
know simple.
while practicing code in console using following commands:
var arr =['carl','erich','rob','nate']; arr ["carl", "erich", "rob", "nate"] arr.push('joe','tim','steve'); 7 arr ["carl", "erich", "rob", "nate", "joe", "tim", "steve"] var arr2 = ['dan','fred','paul']; arr2 ["dan", "fred", "paul"] array.prototype.push.apply(arr, arr2); // intermediate testing commands using splice arr ["joe", "tim", "rob", "dan", "fred", "paul", 0, 4, "carl, erich"] // splice 2 numbers array var removed = arr.splice(6, 4); arr ["joe", "tim", "rob", "dan", "fred", "paul"] // trying insert carl, erich, nate, rob starting @ index 0 var removed = arr.splice(0, 4, ['carl','erich','nate','rob']); arr [array[4] ,"fred", "paul" 0: "carl" 1: "erich" 2: "nate" 3: "rob" length: 4__proto__ also, why mdn documentation use 'remove' insert ?
Comments
Post a Comment