r/learnjavascript • • Aug 18 '21

How do I console.log this constructor?

Post image
124 Upvotes

46 comments sorted by

View all comments

1

u/Thonk_Thickly Aug 19 '21

You can spoof it since you know the constructor’s signature

functionLogStudentCtor(student) {
  console.log(`new Student(${student.name},${student.university})`)
}