0

Why does

 const Todos = function () {
   ...
 }   
 const todos = new Todos();

work just fine, but

 const Todos = () => {
   ...
 }   
 const todos = new Todos();

Give a TypeError: Todos is not a constructor error?

2

3 Answers 3

2

This question is already answered:

When should I use Arrow functions in ECMAScript 6?

Sign up to request clarification or add additional context in comments.

Comments

0

Because it is a Arrow function. Try this const todos = Todos();

Comments

0

The arrow function isn't a constructor so calling it with new isn't correct. It's just a regular function so instead try:

const todos = Todos();

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.