Thanks to visit codestin.com
Credit goes to www.tutorialspoint.com

For Each in a Statement in JavaScript



The for each...in loop iterates a variable overall value of the properties of objects. 

Note − The “for…each..in” is now deprecated. Do not use. 

Syntax

Here’s the syntax −

for each (variablename in object) {
   statement or block to execute
}

Example

Here’s an example, which will not run on any of the web browsers, since “for each..in” is now deprecated −

<!DOCTYPE html>
<html>
   <body>
      <script>
         var myObj = {myProp1:30, myProp2: 40};
         var sum = 0;
         for each (var value in myObj) {
            sum += value;
         }
         document.write(sum);
      </script>
   </body>
</html>
Updated on: 2020-06-16T06:56:09+05:30

133 Views

Kickstart Your Career

Get certified by completing the course

Get Started
Advertisements