1

Let's say I have this class:

function Person(firstName, lastName){
  this.firstName = firstName;
  this.lastName = lastName;
}

I have this array with arguments

var args = ['Jane', 'Smith'];

Is there anyway to instantiate the class with this array? I don't want to change my class if possible.

//Doing this somehow:
var person = new Person(args)

https://jsbin.com/xuyawunoko/edit?js,console

Joe
  • 4,274
  • 32
  • 95
  • 175

0 Answers0