Javascript Array Question 15

Introduction

What is the output of the following code?



let origArray = new Array(4);
origArray[0] = new Array("one","two");
origArray[1] = new Array("three","four");
origArray[2] = new Array("five","six");
origArray[3] = new Array("seven","eight");

let newArray = origArray.slice(1,3);
console.log(newArray); //from www  .  j a va2  s.c om

origArray[1][0] = "octopus";

console.log(newArray); 

newArray[1][1] = "kitten";

console.log(origArray); 


[ [ 'three', 'four' ], [ 'five', 'six' ] ]
[ [ 'octopus', 'four' ], [ 'five', 'six' ] ]
[
  [ 'one', 'two' ],
  [ 'octopus', 'four' ],
  [ 'five', 'kitten' ],
  [ 'seven', 'eight' ]
]



PreviousNext

Related