callable vs. constructable
Last updated
Was this helpful?
Last updated
Was this helpful?
⟩ ⟩ ⟩ ⟩ ⟩ callable vs. constructable
if a can be invoked in the form F()
, it's callable.
if a can be invoked in the form new F()
, it's constructable.
not every function is callable, for example, is a function, but calling it with Map()
throws a
not every function is constructable, for example, is a function, but calling it with new Symbol()
throws a
Array, Error, Function
✅
✅
same effect
Boolean, String, Number
primitive
wrapper object
Date
string
object
Symbol, BigInt
✅
⛔️
Proxy, Map
⛔️
✅
class
⛔️
✅
JS.info ⟩