zoukankan      html  css  js  c++  java
  • js Arrays

    Arrays

    Arrays are zero-indexed lists of values. They are a handy way to store a set of related items of the same type (such as strings), though in reality, an array can include multiple types of items, including other arrays.

    Example 2.25: A simple array

    1 var myArray = [ 'hello''world' ];

    Example 2.26: Accessing array items by index

    1 var myArray = [ 'hello''world''foo''bar' ];
    2 console.log(myArray[3]);   // logs 'bar'

    Example 2.27: Testing the size of an array

    1 var myArray = [ 'hello''world' ];
    2 console.log(myArray.length);   // logs 2

    Example 2.28: Changing the value of an array item

    1 var myArray = [ 'hello''world' ];
    2 myArray[1] = 'changed';

    While it's possible to change the value of an array item as shown in “Changing the value of an array item”, it's generally not advised.

    Example 2.29: Adding elements to an array (增加元素到数组)

    1 var myArray = [ 'hello''world' ];
    2 myArray.push('new');

    Example 2.30: Working with arrays

    1 var myArray = [ 'h''e''l''l''o' ];
    2 var myString = myArray.join('');   // 'hello'
     
    3 var mySplit = myString.split('');  // [ 'h', 'e', 'l', 'l', 'o' ]
  • 相关阅读:
    Apache基本设置
    主流无线传输技术GPRS与CDMA之对比
    光波分复用系统(WDM)技术要求
    IPv6报头结构以及与IPv4的比较
    网络设计师训练资料
    802.11b/11a/11g横向比较
    交换机术语
    无线局域网技术白皮书
    无线网络基础知识
    校验码
  • 原文地址:https://www.cnblogs.com/youxin/p/2238626.html
Copyright © 2011-2022 走看看