Javascript Number iters()

Description

Javascript Number iters()


// 'this' in a generator-expression non-strict function produces the expected
// object./*from  www.j  a v  a  2s  .  c o m*/

Number.prototype.iters = function () {
    return [(this for (x of [0])),
            (this for (y of [0]))];
};

var [a, b] = (3).iters();
var three = a.next();
assertEq(Object.prototype.toString.call(three), '[object Number]');
assertEq(+three, 3);
assertEq(b.next(), three);



PreviousNext

Related