Trying to get the class ID of a party member and store it in a variable.

I googled around and found a few ways to do this. To my surprise, none of them worked. What I'm trying to do is the title - I want to grab the class ID of a party member (let's say Party Member #1), figure out what class they are, and store their class ID into a variable.

What I've tried:

Code:
var actor = $gameParty.members(0).currentClass().name
$gameVariables.setValue(13, actor);

This should grab the class ID for the first member of the party. The variable 13 returns 0.

Code:
var actor = $gameParty.members(0);
$gameVariables.setValue(13, actor._classId);

Same thing. The variable 13 returns 0.

I don't understand what I'm supposed to do. I figured this would be a simple task, but it seems not.
You just want the class ID?
var actorID = $gameActors.actor(id)._classID
$gameVariables.setValue(13, actorID)
Although I didn't show you in the party's scope, did I?
Several ways to do that, I'll show you one. I want to find the class ID of the second position of my party.
var actor = $gameParty.members()[1]._classId;

$gameParty.members is a method, you can't pass it the position of the party members, it returns an array with all of the party memeberrs.

The result of that call on a party of four would look like this:
$gameParty.members() <----will return an array like this [Game-Actor, Game-Actor, Game-Actor, Game-Actor]

The first position of an array is index 0, so to access the first party member, you'd do this:
var actorID = $gameParty.members()[0]._classId
That explains it. I was definitely misunderstanding how the party member grabbing worked. Thanks, I can confirm it works.
Hi there!
I think this can solve too:

Code:
var casa = $gameParty.members()[2]._classId;
$gameVariables.setValue(1, casa);
$dataClasses[casa].name;

$dataClasses[classId].name => Will return the name of the class
You can put the name in a variable too ^^
Just to add on, if you want to get classId of a targeted member (for example enemy skills), to store as variable you can do this;

var x = $gameParty._targetActorId;
var actor = $gameActors.actor(x)._classId;

$gameVariables.setValue(13, actor);

Original thread: https://forums.rpgmakerweb.com/threads/trying-to-get-the-class-id-of-a-party-member-and-store-it-in-a-variable.111861/