Pushing array of objects

Not much fond with Javascript, so I’m not sure if I can do something like this:

class __dude{
  constructor(name,age){    
    this.name=name;
    this.age=age;  
  }
}

$dude1 = new __dude('Jack',32);
$dude2 = new __dude('Sam',34);

$dudes = $dude1;
$dudes.push($dude2);

$dude1_name= $dudes[0].name;
$dude1_age= $dudes[0].age;

$dude2_name= $dudes[1].name;
$dude2_age= $dudes[1].age;

Would this make sense, or there is a better way in Javascript?

What is this? That’s just reassigning it to a different name.
And why $ prefix? Why no const / let statements?
You need to study more :slight_smile:.

Also, start using strict mode by adding 'use strict'; on top of each of your javascript file. Or even better, use modules which uses strict mode by default and allows you to split code into multiple files.

And regarding array, see:

There is a bunch of examples.

was just missing a $dudes = []; its working fine now.