Why are some JavaScript constructors not functions?

前端 未结 3 1213
闹比i
闹比i 2021-02-14 19:43

Clarification:
\"JavaScript constructor\" should be more properly be written as \"javascript constructor\" to emphasize that the constructors considered are not just the nat

3条回答
  •  攒了一身酷
    2021-02-14 20:33

    The question might actually be paraphrased as:

    "Do JavaScript (ECMAScript) language conventions apply to and qualify other components of the browser such as the programming objects that interface the DOM?"

    The original question uses objects that are supposedly of type Function and used as constructors. The examples shows a dichotomy exists with the programming environment and the DOM interface in how they are represented.

    If there is this actual dichotomy, is it made explicit?

    This may be the actual issue. If so, the original question should be preceded by this to direct attention to the real problem.

    references:

    • W3C HTML 5 specification
    • W3C WebIDL interface definition language specification
    • W3C DOM
    • Mozilla JavaScript technologies overview
    • Mozilla DOM
    • Mozilla ECMAScript references
    • ecma262-5.com

    ECMAScript language constructor details:

    • 4.3.4 constructor
    • 13.2.2 [[Construct]]
    • 15.3.4.5.2 [[Construct]].
    • "every built-in constructor has the Function prototype object"
      quoting section 15 Standard Built-in ECMAScript Objects
    • "it is expected that the computational environment of an ECMAScript program will provide ... certain environment-specific host objects, whose description and behaviour are beyond the scope of this specification"
      quoting section 4 Overview

提交回复
热议问题