Coding⏱️ 2 min read📅 2026-05-31

How to Fix: Javascript "Not a Constructor" Exception while creating objects

The error occurs because the function Project is not being called as a constructor with the new keyword.

Quick Answer: Use the new keyword when creating an instance, e.g. var newProj = new Project(a,b,c);

The 'Javascript "Not a Constructor" Exception' occurs when the JavaScript interpreter is unable to recognize your function as a constructor. This can happen due to various reasons such as missing or incorrect use of the 'new' keyword, incorrect placement of the function definition, or using reserved keywords as variable names.

🛑 Root Causes of the Error

  • Missing or incorrect use of the 'new' keyword.

🔧 Proven Troubleshooting Steps

Method 1: Using the 'new' Keyword Correctly

  1. Step 1: Ensure that you use the 'new' keyword when creating a new instance of your function.

Method 2: Correct Placement of Function Definition

  1. Step 1: Ensure that your function definition is placed outside the constructor block, or use the 'function' keyword before the name of your function.

✨ Wrapping Up

To fix this issue, simply ensure that you are using the 'new' keyword correctly and that your function definition is in the correct place. By following these steps, you should be able to resolve the 'Javascript "Not a Constructor" Exception'.

Did this fix your problem?

If not, try searching for specific error codes.

🔍 Search Error Database

❓ Frequently Asked Questions