国产av日韩一区二区三区精品,成人性爱视频在线观看,国产,欧美,日韩,一区,www.成色av久久成人,2222eeee成人天堂

JavaScript array object property length and two-dimensional array

Array object attribute length

An array is actually an "array object". Thinking of an array as an "object" is to use the properties or methods of the array object.

In JS, all content is "object".

Then, length is a property of the array object. For example: var len = arrObj.length;

length attribute can dynamically obtain the length of the array.

<!DOCTYPE HTML>
<html>
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
        <title>php.cn</title>
        <script>
            var arr = ["濤哥" , "男" , 24, "大專" , "北京科技大學" ];
                document.write(arr.length);
        </script>
    </head>
    <body>
    </body>
</html>


Two-dimensional array

Give an array element , assign the value of an array, then this array is a "two-dimensional array".

Create a simple two-dimensional array:

<!DOCTYPE HTML>
<html>
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
        <title>php.cn</title>
        <script>          
            //使用[]方式創(chuàng)建一個數(shù)組
            var arr = [
                [1,2,3,4],
                [4,5,6,7],
                [8,9,10,11]
            ];         
            document.write(arr);        
        </script>
    </head>
    <body>
    </body>
</html>
  • A two-dimensional array must be implemented with two layers of loops. In other words, cycles within cycles.

  • Access to two-dimensional arrays: The array name is followed by multiple consecutive brackets []. The first bracket [] represents the first-dimensional array, and the second bracket [] Represents the second dimension array.

<!DOCTYPE HTML>
<html>
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
        <title>php.cn</title>
        <script>          
            //使用[]方式創(chuàng)建一個數(shù)組
            var arr = [
                [1,2,3,4],
                [4,5,6,7],
                [8,9,10,11]
            ];         
            document.write(arr[1][1]);        
        </script>
    </head>
    <body>
    </body>
</html>


Continuing Learning
||
<!DOCTYPE HTML> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8"> <title>php.cn</title> <script> var arr = ["濤哥" , "男" , 24, "大專" , "北京科技大學" ]; document.write(arr.length); </script> </head> <body> </body> </html>
submitReset Code