javascript problems -- 15. Class array objects

I. conclusion

One sentence summary:

Class array objects are just like arrays, which access elements through numeric subscripts. They also have the length attribute, but there are no array methods, such as arguments in functions
function f1() {
  console.log(arguments);
  console.log(arguments instanceof Array);
  console.log(arguments instanceof Object);
}
f1(1,32,43,4);

 

 

1. What are the common array like objects?

1. Function implied argument arguments
2. The elements obtained by the getElementsByTagName method of the document: for example, let lis=document.getElementsByTagName('li ');

 

 

 

2, Class array object

Video location of corresponding courses of Blog:

 

 1 <!DOCTYPE html>
 2 <html lang="en">
 3 <head>
 4     <meta charset="UTF-8">
 5     <title>Class array object</title>
 6 </head>
 7 <body>
 8 <!--
 9 
10 Class array objects are just like arrays, which access elements through numeric subscripts length Properties, but there are no array methods, such as arguments
11 
12 Has: numeric index subscript to object element and length Attribute tells us the number of elements of the object;
13 Does not have: such as forEach,indexOf The method of equal array object;
14 
15 -->
16 
17 <!--1,Class array instance 1-->
18 <!--<ul>-->
19 <!--    <li></li>-->
20 <!--    <li></li>-->
21 <!--    <li></li>-->
22 <!--</ul>-->
23 <!--<script>-->
24 <!--    let lis=document.getElementsByTagName('li');-->
25 <!--    console.log(lis);-->
26 <!--    console.log(lis instanceof Array);-->
27 <!--    console.log(lis instanceof Object);-->
28 <!--</script>-->
29 
30 <!--2,Class array instance 2-->
31 <script>
32     function f1() {
33         console.log(arguments);
34         console.log(arguments instanceof Array);
35         console.log(arguments instanceof Object);
36     }
37     f1(1,32,43,4);
38 </script>
39 </body>
40 </html>

Tags: Attribute

Posted on Sat, 11 Apr 2020 07:15:36 -0700 by gamesmstr