Convert JS array to an object


var languages = ["english", "hindi", "german", "spanish"];
var languagesObj = { ...languages };
console.log(languagesObj); // {0: "english", 1: "hindi", 2: "german", 3: "spanish"}

Comments

Popular posts from this blog

Interview Question on Ruby on Rails

Inserting and Moving elements inside Ruby Array