Home > other >  Why a function is a subset of an object in typescript?
Why a function is a subset of an object in typescript?

Time:08-31

type ccc = (() => 22) extends Record<string|symbol,any> ? true : false // true

I don't understand why it was designed this way

CodePudding user response:

Because a function is an object in JavaScript.

In JavaScript, functions are first-class objects, because they can have properties and methods just like any other object. What distinguishes them from other objects is that functions can be called. In brief, they are Function objects.

  • Related