@jgCarroll/

constructorFunctions

JavaScript

A common interview question

fork
loading
main.js
1
2
3
4
5
6
7
8
9
10
11
12
function User(firstName, lastName, age, gender) {
  this.firstName = firstName
  this.lastName = lastName
  this.age = age
  this.gender = gender
}

const user1 = new User('John', 'Smith', 26, 'male')
console.log(user1)

const user200 = new User('Jill', 'Mackintosh', 29, 'female')
console.log(user200)
Native Browser JavaScript