assign array to another array javascript

JavaScript
var ar = ["apple","banana","canaple"];
var bar = Array.from(ar);
alert(bar[1]); // alerts 'banana'

// Notes: this is for in In ES6, works for an object of arrays too!/* Copying arrays or parts of arrays in JavaScript */

var fruit = ["apple", "banana", "fig"]; // Define initial array.
console.log(fruit); // ["apple", "banana", "fig"]

// Copy an entire array using .slice()
var fruit2 = fruit.slice(); 
console.log(fruit2); // ["apple", "banana", "fig"]

// Copy only two array indicies rather than all three
// From index 0 (inclusive) to index 2 (noninclusive)
var fruit3 = fruit.slice(0,2); 
console.log(fruit3); // ["apple", "banana"]// 1) Array of literal-values (boolean, number, string) 
const type1 = [true, 1, "true"];

// 2) Array of literal-structures (array, object)
const type2 = [[], {}];

// 3) Array of prototype-objects (function)
const type3 = [function () {}, function () {}];

Source

Also in JavaScript: