zjrJS.Doc. addArrayComprehension() - Stable Test Suite for zjrJS

This information lives on a webpage hosted at the following web address: 'https://www.omegajunior.net/code/zjrjs/stable.php'.

How to use zjrJS.Doc. addArrayComprehension()

Used zjrJS Version:

Stable Minified version 20141202t2322 of zjrJS.


 

Declaration
zjrJS.Doc.addArrayComprehension()


Goal
To add Array Comprehension from EcmaScript 5 to older browsers. (The browser's javascript implementation is tested to see whether addition should be skipped.)

Typical usage
Call this inside the initialisation function for your web application, before using any of the Array Comprehension abilities. Note that our implementations probably run slower than native ones.

The following abilities are added to the Array prototype:


The following ability is added to the Array constructor:


We have created our implementation by combining the explanations in the EcmaScript Language Specification Version 5, with the existing implementations shown at the Mozilla Developer Network, and other internet resources.


Member Type
Method (no return value).

Parameters
None.

Dependencies
None.

Example
<!DOCTYPE html>
<html>
<head>
<script type="text/javascript" src="zjrJS.version.js" id="zjrJS"></script>
<script type="text/javascript">/* <![CDATA[ */
zjrJS.Doc.addArrayComprehension();

[ "apple", "banana", "coconut", "dumpling" ].forEach(
my.list, zjrJS.Doc.eid("placeholder")
);

var my=({});
my.list = function (itemValue, itemIndex, allItems ) { "use strict";
var D = zjrJS.Doc, li = D.cE( "li" );
D.aC( D.cT( itemValue ), li );
D.aC( li, this );
D = null;
};
/* ]]> */</script>
</head>
<body>
<h1>Which of these is not a fruit?</h1>
<ol id=placeholder></ol>
</body>
</html>

Download:

Download zjrJS’ latest stable build (20141202t2322) minified (7.1KB).

Download zjrJS’ latest stable build (20141202t2322) (11.9KB).

Clicky Analytics