javascript中部分不能使用call apply调用来重写的构造函数

Posted 走的夜路多了会碰鬼

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了javascript中部分不能使用call apply调用来重写的构造函数相关的知识,希望对你有一定的参考价值。

  This tests if TypeError is thrown or not when we call a constructor as a normal function.
   
  On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
   
   
  PASS ArrayBuffer() threw exception TypeError: Constructor ArrayBuffer requires ‘new‘.
  SKIP AudioContext is not implemented.
  PASS FormData() threw exception TypeError: Failed to construct ‘DOMFormData‘: Please use the ‘new‘ operator, this DOM object constructor cannot be called as a function..
  PASS DataView() threw exception TypeError: Constructor DataView requires ‘new‘.
  PASS EventSource() threw exception TypeError: Failed to construct ‘EventSource‘: Please use the ‘new‘ operator, this DOM object constructor cannot be called as a function..
  PASS FileReader() threw exception TypeError: Failed to construct ‘FileReader‘: Please use the ‘new‘ operator, this DOM object constructor cannot be called as a function..
  PASS Float32Array() threw exception TypeError: Constructor Float32Array requires ‘new‘.
  PASS Float64Array() threw exception TypeError: Constructor Float64Array requires ‘new‘.
  PASS Audio() threw exception TypeError: Failed to construct htmlAudioElement‘: Please use the ‘new‘ operator, this DOM object constructor cannot be called as a function..
  PASS Image() threw exception TypeError: DOM object constructor cannot be called as a function..
  PASS Option() threw exception TypeError: Failed to construct ‘HTMLOptionElement‘: Please use the ‘new‘ operator, this DOM object constructor cannot be called as a function..
  PASS Int16Array() threw exception TypeError: Constructor Int16Array requires ‘new‘.
  PASS Int32Array() threw exception TypeError: Constructor Int32Array requires ‘new‘.
  PASS Int8Array() threw exception TypeError: Constructor Int8Array requires ‘new‘.
  PASS MessageChannel() threw exception TypeError: Failed to construct ‘MessageChannel‘: Please use the ‘new‘ operator, this DOM object constructor cannot be called as a function..
  PASS SharedWorker() threw exception TypeError: Failed to construct ‘SharedWorker‘: Please use the ‘new‘ operator, this DOM object constructor cannot be called as a function..
  PASS Uint16Array() threw exception TypeError: Constructor Uint16Array requires ‘new‘.
  PASS Uint32Array() threw exception TypeError: Constructor Uint32Array requires ‘new‘.
  PASS Uint8Array() threw exception TypeError: Constructor Uint8Array requires ‘new‘.
  PASS WebKitCSSMatrix() threw exception TypeError: Failed to construct ‘CSSMatrix‘: Please use the ‘new‘ operator, this DOM object constructor cannot be called as a function..
  PASS WebKitPoint() threw exception TypeError: Failed to construct ‘DOMPoint‘: Please use the ‘new‘ operator, this DOM object constructor cannot be called as a function..
  PASS WebSocket() threw exception TypeError: Failed to construct ‘WebSocket‘: Please use the ‘new‘ operator, this DOM object constructor cannot be called as a function..
  PASS Worker() threw exception TypeError: Failed to construct ‘Worker‘: Please use the ‘new‘ operator, this DOM object constructor cannot be called as a function..
  PASS XMLHttpRequest() threw exception TypeError: Failed to construct ‘XMLHttpRequest‘: Please use the ‘new‘ operator, this DOM object constructor cannot be called as a function..
  PASS XSLTProcessor() threw exception TypeError: Failed to construct ‘XSLTProcessor‘: Please use the ‘new‘ operator, this DOM object constructor cannot be called as a function..
  PASS successfullyParsed is true
   
  TEST COMPLETE

https://chromium.googlesource.com/chromium/blink/+/8fefa5dc50de232902601612bf6429f08779abc9/LayoutTests/fast/dom/call-a-constructor-as-a-function-expected.txt

以上是关于javascript中部分不能使用call apply调用来重写的构造函数的主要内容,如果未能解决你的问题,请参考以下文章

JavaScript中的Array.prototype.slice.call()方法学习

javascript学习系列(20):数组中的bind,apply,call

在 jquery post call 中不能 require_once

Jquery第四课 Javascript中this的使用方法

Javascript中call的使用

为啥使用javascript函数包装器(在coffeescript中添加)“.call(this)”