Node forEach() function Last Updated : 15 Jan, 2024 Summarize Comments Improve Suggest changes Share Like Article Like Report forEach() is an array function Node that is used to iterate over items in a given array. Syntax: array_name.forEach(function)Parameter: This function takes a function (which is to be executed) as a parameter. Return type: The function returns an array element after iteration. The program below demonstrates the working of the function: Example 1: Below is the code example of forEach() function JavaScript const arr = ['cat', 'dog', 'fish']; arr.forEach((element) => { console.log(element); }); Output: catdogfishExample 2: Below is the code example of forEach() function JavaScript const arr = [1, 2, 3, 8, 7]; arr.forEach((element) => { console.log(element); }); Output: 12387 Comment More infoAdvertise with us Next Article Node forEach() function T Twinkl Bajaj Follow Improve Article Tags : Web Technologies Node.js NodeJS-function Similar Reads D3.js node.each() Function The node.each() function is used to evaluate a function for each node in Breadth First Order. In this, every node is visited exactly one time. This function is called repeatedly for each descendant node. Syntax: node.each(function); Parameters: This function accepts a single parameter as mentioned a 2 min read D3.js node.eachAfter() Function The node.eachAfter() function is used to invoke a particular function for each node but in a post-order-traversal order. It visits each node in post-traversal order and performs an operation on that particular node and each of its descendants. Syntax: node.eachAfter(function); Parameters: This funct 2 min read D3.js node.eachBefore() Function The node.eachBefore() function is used to invoke a particular function for each node but in a pre-order-traversal order. It visits each node in pre-traversal order and performs an operation on that particular node and each of its descendants. Syntax: node.eachBefore(function); Parameters: This funct 2 min read D3.js node.count() Function The node.count() function of D3.js library is used to count the number of leaves under a particular node and append it as a value property to the object. If the node given is itself a leaf node then the count is one. Syntax: node.count(); Parameters: This function does not take any parameter. Return 2 min read D3.js node.sum() Function The node.sum() function in d3.js is used to evaluate the specified value function for a particular node. The node.value property of this function contains the value returned by the specified function. Syntax: node.sum(value); Parameters: This function accepts a single parameter as mentioned above an 2 min read Like