What happens if you try to call a regular function as if it were a constructor function?

Question

Grade: Education Subject: Support
What happens if you try to call a regular function as if it were a constructor function?
Asked by:
88 Viewed 88 Answers

Answer (88)

Best Answer
(231)
If you call a regular function with the `new` keyword, JavaScript will throw a `TypeError`. It expects a constructor function, not a regular function, when `new` is used. This is a crucial distinction to avoid unexpected behavior.