- Data Structure
- Networking
- RDBMS
- Operating System
- Java
- MS Excel
- iOS
- HTML
- CSS
- Android
- Python
- C Programming
- C++
- C#
- MongoDB
- MySQL
- Javascript
- PHP
- Physics
- Chemistry
- Biology
- Mathematics
- English
- Economics
- Psychology
- Social Studies
- Fashion Studies
- Legal Studies
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
What is 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>
Advertisements