Learning Destructuring assignment in Javascript and when trying to have an array in object destructuring, just first letter return to console, why it’s happening?
function splitter(name) {
const [fName, lName] = name.split(" ");
return { fName, lName };
}
const {fName: [firstWord],lName} = splitter("John Doe");
console.log(splitter("John Doe"));
console.log({fName: [firstWord],lName});
console.log(firstWord);
console.log(lName);