Hello I have a function and I would like to make variables from returned array, is it possible?
var food,car=getItems();
function getItems(){
var array=["pizza","audi"];
return array;
}
Just wrap your variables in [] to use destructuring assignment (no jQuery needed):
var [food,car]=getItems();
var [food,car]=getItems();
function getItems(){
var array=["pizza","audi"];
return array;
}
console.log(food,car)
pizzatofoodandauditocar?