zhiqingstudy

Be a young person with knowledge and content

The forEach () method is used to call each element of the array and pass the element to the callback function

Main usage scenario: traverse each element of the array

grammar

Traversal array. forEach (function (current array element, current element index number) {//function body})

        const arr=['red','green','blue']
        arr.forEach(function(item,index){
            console.log(item,index)
        })

be careful:

ForEach mainly traverses arrays

The current array element of the parameter must be written, and the index number is optional

comment
head sculpture
Code:
Related

The art of interpersonal communication and communication

A code of conduct that regulates and regulates interpersonal relationships

The importance of interpersonal relationships




Unless otherwise specified, all content on this website is original. If the reprinted content infringes on your rights, please contact the administrator to delete it
Contact Email:2380712278@qq.com

Filing number:皖ICP备19012824号