JavaScript Feature Reference: TypedArray Object Web Browser Support Test

Last reviewed/updated: 04 Jan 2018 | Published: 01 Jan 2018 | Status: Active
Web browser support: Internet Explorer 10+, Edge 12+, Firefox 6+, Chrome 30+, Opera 17+

1. Introduction

In this web page there are two web browser JavaScript feature support tests; 1.) a feature implementation test, and 2.) a feature capability test. First, the implementation test is run. The implementation test determines if the web browser recognizes the JavaScript TypedArray object. The implementation test is a simple test for the presence of web browser support, and a definitive test for the absence of web browser support. If the web browser does not recognize the JavaScript TypedArray object, the testing is stopped and the implementation test reports: Fail (no support): The web browser does not recognize the JavaScript TypedArray object. The web browser does not support the JavaScript TypedArray object.

If the web browser recognizes the JavaScript TypedArray object, the capability test is run. The capability test determines if the web browser's implementation of the JavaScript TypedArray object includes support for at least one TypedArray object capability. The capability test is a more definitive, albeit not an all inclusive, test for the presence of web browser support. If the web browser's implementation of the JavaScript TypedArray object includes support for the tested capability, the capability test reports: Pass (at least partial/possibly full support): The web browser recognizes the JavaScript TypedArray object, and supports at least one TypedArray object capability. The web browser at least partially/possibly fully supports the JavaScript TypedArray object. Positive determination of full web browser support is beyond the scope of this test. If the web browser's implementation of the JavaScript TypedArray object does not include support for the tested capability, the capability test reports: Pass/Fail (partial support): The web browser recognizes the JavaScript TypedArray object, but does not support at least one TypedArray object capability. The web browser partially supports the JavaScript TypedArray object.

The web browser support test source code is shown in Section 2.1. The web browser support test source code is run in Section 2.2, which shows the web browser support test result.

1.1. TypedArray Object Web Browser Support

Pass (at least partial/possibly full support): IE10+, ED12+, FF4+, SF5.1+, CH9+, OP11.60+.

1.2. Abbreviations

  • IE = Internet Explorer.
  • ED = Edge = EdgeHTML rendering engine (ED12+) and/or Edge browser (ED20+).
  • FF = Firefox.
  • SF = Safari.
  • CH = Chrome.
  • OP = Opera.

2. TypedArray Object Web Browser Support Test

2.1. Web Browser Support Test Source Code

<p id='testId'><b>Fail</b> (no support): The web browser does not recognize the JavaScript <code>TypedArray</code> object. The web browser does not support the JavaScript <code>TypedArray</code> object.</p><!-- Hard code Fail because web browser no support error stops JavaScript execution. -->

<script>
// Call typed array constructor with new to instantiate typed arrays. Constructor returns a TypedArray object which inherits prototype from Object, not Array (window.TypedArray property does not exist).
var typedArrayOne = new Int8Array(); // Instantiate typedArrayOne with zero 8-bit elements. typedArrayOne has zero elements (length === 0). Each element is 8 bits. 8 bits = 1 byte. One 8-bit element requires one byte. Zero 8-bit elements require zero bytes (byteLength === 0).
var typedArrayTwo = new Int8Array(2); // Instantiate typedArrayTwo with two 8-bit elements. typedArrayTwo has two elements (length === 2). Each element is 8 bits. 8 bits = 1 byte. One 8-bit element requires one byte. Two 8-bit elements require two bytes (byteLength === 2).
var typedArrayThree = new Int16Array(2); // Instantiate typedArrayThree with two 16-bit elements. typedArrayThree has two elements (length === 2). Each element is 16 bits. 8 bits = 1 byte. One 16-bit element requires two bytes. Two 16-bit elements require four bytes (byteLength === 4).
var typedArrayFour = new Int8Array(3); // Instantiate typedArrayFour with three 8-bit elements holding no values.
typedArrayFour[0] = 10; // Assign typedArrayFour element index 0 value 10.
typedArrayFour[1] = 20; // Assign typedArrayFour element 1 index value 20.
typedArrayFour[2] = typedArrayFour[0] + typedArrayFour[1]; // Assign typedArrayFour element index 2 value typedArrayFour[0] plus typedArrayFour[1] (ie, 10 + 20).
var typedArrayFive = new Int8Array([11,22,33]); // Instantiate typedArrayFive with three 8-bit elements holding values 11, 22, and 33 from passed array.
var typedArraySix = new Int8Array(typedArrayFive); // Instantiate typedArraySix with 8-bit elements holding values from passed typed array.
if (window.typedArrayOne){ // Identical to if (typedArrayOne).
 var element = document.getElementById("testId");
 if ((typeof typedArrayOne === "object") && typedArrayOne instanceof Object && !(typedArrayOne instanceof Array) && Object.prototype.isPrototypeOf(typedArrayOne) && !Array.prototype.isPrototypeOf(typedArrayOne) && !Array.isArray(typedArrayOne) && (typedArrayOne.length === 0) && (typedArrayOne.byteLength === 0) && (typedArrayTwo.length === 2) && (typedArrayTwo.byteLength === 2) && (typedArrayThree.length === 2) && (typedArrayThree.byteLength === 4) && (typedArrayFour.length === 3) && (typedArrayFour[0] === 10) && (typedArrayFour[2] === 30) && (typedArrayFive.length === 3) && (typedArrayFive[0] === 11) && (typedArrayFive[2] === 33) && (typedArraySix.length === 3) && (typedArraySix[0] === 11) && (typedArraySix[2] === 33)){
  element.innerHTML = "<b>Pass</b> (at least partial/possibly full support): The web browser recognizes the JavaScript <code>TypedArray</code> object, and supports at least one <code>TypedArray</code> object capability. The web browser at least partially/possibly fully supports the JavaScript <code>TypedArray</code> object. Positive determination of full web browser support is beyond the scope of this test.";
 } else {
  element.innerHTML = "<b>Pass/Fail</b> (partial support): The web browser recognizes the JavaScript <code>TypedArray</code> object, but does not support at least one <code>TypedArray</code> object capability. The web browser partially supports the JavaScript <code>TypedArray</code> object.";
 }
}
</script>

2.2. Web Browser Support Test Result

Fail (no support): The web browser does not recognize the JavaScript TypedArray object. The web browser does not support the JavaScript TypedArray object.


3. Resources And Additional Information