Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

247
Views
Why JS anonymous function is not a constructor
// 1.declare a function 
function F(){}
F.prototype = null;
F.__proto__ = null;
var f = new F();//successful
console.log(f);


// 2.function assignment expression
var F2 = function (){}
F2.prototype =  null;
F2.__proto__ =  null;
var f2 = new F2();//successful
console.log(f2);

// 3.anonymous function
var F3 = (()=>{})
console.log(typeof F3);//"function"
var f3 = new F3();//Uncaught TypeError TypeError: F3 is not a constructor

I'm new to JS and I'm learning it's grammar in nodejs.

The three ways to create functions and new a object by the function are listed above.

prototype or __proto__ appears to be not affecting new a object , so I can assign them to null.

I'm curious why the anonymous function can not be used behind new, can I assign some properties to the anonymous function to make it support new ?

about 4 years ago · Juan Pablo Isaza
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!