MZ Database Script calls

Okay, I must be missing some step when trying to call this information, but I can't find it online.
This should, according to my understanding, populate 'K' with the array returned from $gameParty.weapons();
And then using '...' spread operator on the array, I'd generate a list of choices based on the array itself.

I've already done a partial test using ["a","b","c"]. And that works. The problem lies when I try to get the data of party weapons. So I'm clearly not using it right. I would very much appreciate some help on this one. Until then, I'm going to head to bed and tackle it again when I wake up.
Also of note, I had already tried declaring 'K' as an empty array before hand, though with JS that shouldn't be needed.
*Note - I'm using Visustella's Message Core, for Extended Choices, letting me go past the default # of 6. If that matters*.
JavaScript:
let k = $gameParty.weapons();

$gameMessage.setChoices([...k], 0, 0);
$gameMessage.setChoiceBackground(1);
$gameMessage.setChoicePositionType(2);
$gameMessage.setChoiceCallback(n=>{
    $gameVariables.setValue(1,n);
});
this.setWaitMode("message");

Also, if possible, is there a way to also call the items names, based on the IDs provided from the data call? Logically speaking it should be a thing, but I can't find any references online on how to do so. Perhaps it's just me not using the right search words.

Again thank you in advance.
I guess it should be

Code:
const weaponNames = $gameParty.weapons().map(weapon => weapon.object().name)
$gameMessages.setChoices(weaponNames, 0, 0)
...
Okay, I figured out what was wrong. Thanks to a deep sleep, I forgot to use the console to find out what was happening.

For those wondering, $gameWeapons(); indeed does return an array. But the array returned is filled with Objects which each have their own properties that store all the crucial information, which is why it wasn't working.

$gameMessages.setChoices([arrary], 0, 0); asks for an array, but I don't think the Game_Interpreter can process how to deal with Objects, and is expecting a String or Int array.

The problem I was running into was expecting the script call to return an array with only the IDs. So don't be like me and use the dev console when doing these things. Saves headache and trouble.

Working Code for anyone who has this issue:
JavaScript:
// Create an empty Object to store the information
let weaponNamesObj = {};
// Create an empty array to be used in the loop.
let weaponNamesList = [];
// Populate the Object with game information
weaponNamesObj = $gameParty.weapons();
// Run a loop.
for (let i = 0; i < weaponNamesObj.length; i++) {
    // Populate the empty array with Names from the Object
    weaponNamesList.push(weaponNamesObj[i].name);
}

// Run the $gameMessage.setChoices command as normal.
$gameMessage.setChoices([...weaponNamesList], 0, 0);
$gameMessage.setChoiceBackground(1);
$gameMessage.setChoicePositionType(2);
$gameMessage.setChoiceCallback(n=>{
    $gameVariables.setValue(1,n);
});
this.setWaitMode("message");
Thread closed

Original thread: https://forums.rpgmakerweb.com/threads/database-script-calls.143799/