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
  • 5,210
  • 27
  • 83
  • 156

0 Answers0