★ wanayoo — archive 1999 https://developer.mozilla.org/zh-CN/docs/Web/JavaScript/Reference/Global_Objects/Array/valuesNouvelle recherche | Portail wanayoo
mozilla
您的搜索结果

    Array.prototype.values()

    我们的志愿者还没有将这篇文章翻译为 中文 (简体) 。加入我们帮助完成翻译!

    This is an experimental technology, part of the Harmony (ECMAScript 6) proposal.
    Because this technology's specification has not stabilized, check the compatibility table for usage in various browsers. Also note that the syntax and behavior of an experimental technology is subject to change in future version of browsers as the spec changes.

    Summary

    The values() method returns a new Array Iterator object that contains the values for each index in the array.

    Syntax

    arr.values()

    Examples

    Example: Iteration using for...of loop

    var arr = ['w', 'y', 'k', 'o', 'p'];
    var eArr = arr.values();
    // your browser must support for..of loop
    // and let-scoped variables in for loops
    for (let letter of eArr) {
      console.log(letter);
    }
    

    Example: Alternative iteration

    var arr = ['w', 'y', 'k', 'o', 'p'];
    var eArr = arr.values();
    console.log(eArr.next().value); // w
    console.log(eArr.next().value); // y
    console.log(eArr.next().value); // k
    console.log(eArr.next().value); // o
    console.log(eArr.next().value); // p
    

    Specifications

    Specification Status Comment
    ECMAScript 6 (ECMA-262)
    The definition of 'Array.prototype.values' in that specification.
    Draft Initial definition.

    Browser compatibility

    Feature Chrome Firefox (Gecko) Internet Explorer Opera Safari
    Basic support 38 Not supported Not supported Not supported Not supported
    Feature Android Chrome for Android Firefox Mobile (Gecko) IE Mobile Opera Mobile Safari Mobile
    Basic support Not supported Not supported Not supported Not supported Not supported Not supported

    Firefox-specific notes

    See also

    文档标签和贡献者

    此页面的贡献者有: Mingun, P0lip, fscholz, arai
    最后编辑者: arai,
    隐藏侧边栏