Alternative code to classes in Javascript?
A short review;


In stacktraces, person will be a nameless function, use function person(){} instead
There is no good reason to have different names (first->firstName) for your attributes. Using the same name allows you to use some nifty JS syntax
Your code will create a new function for each instance of person, unless you have a smart VM, that could be heavy on memory
I would extend the .prototype of person for fullName to prevent that memory issue
I also strive to name functions with a &lt;verb&gt;&lt;thing&gt; scheme so I would call it getFullName()
Ideally functions that are akin to a class are capitalized, so person -> Person


So, all in all, this is my counter proposal:



    function Person(firstName, lastName, age, gender){
      Object.assign(this, {firstName, lastName, age, gender});
    }

    Person.prototype.getFullName = function personGetFullName(){
      return this.firstName + " " + this.lastName;
    }

    const John = new Person("John", "Anderson", 21, "Male");
    const Mary = new Person("Mary", "Smith", 32, "Female");
    console.log(John.firstName);
    console.log(Mary.getFullName());