for (var key in validation_messages) {
    // skip loop if the property is from prototype
    if (!validation_messages.hasOwnProperty(key)) continue;

    var obj = validation_messages[key];
    for (var prop in obj) {
        // skip loop if the property is from prototype
        if (!obj.hasOwnProperty(prop)) continue;

        // your code
        alert(prop + " = " + obj[prop]);
    }
}
Answer from AgileJon on Stack Overflow
🌐
MDN Web Docs
developer.mozilla.org › en-US › docs › Web › JavaScript › Reference › Global_Objects › Object › entries
Object.entries() - JavaScript | MDN
// Using for...of loop const obj = { a: 5, b: 7, c: 9 }; for (const [key, value] of Object.entries(obj)) { console.log(`${key} ${value}`); // "a 5", "b 7", "c 9" } // Using array methods Object.entries(obj).forEach(([key, value]) => { console.log(`${key} ${value}`); // "a 5", "b 7", "c 9" }); Polyfill of Object.entries in core-js ·
🌐
Google
developers.google.com › google workspace › apps script › create a mail merge with gmail & google sheets
Create a mail merge with Gmail & Google Sheets | Apps Script | Google for Developers
* @param {string} subject_line to search for draft message * @return {object} containing the subject, plain and html message body and attachments */ function getGmailTemplateFromDrafts_(subject_line) { try { // get drafts const drafts = GmailApp.getDrafts(); // filter the drafts that match subject line const draft = drafts.filter(subjectFilter_(subject_line))[0]; // get the message object const msg = draft.getMessage(); // Handles inline images and attachments so they can be included in the merge // Based on https://stackoverflow.com/a/65813881/1027723 // Gets all attachments and inline image
🌐
Laravel
laravel.com › docs › 12.x › validation
Validation | Laravel 12.x - The clean stack for Artisans and agents
For more information on working with this object, check out its documentation. So, in our example, the user will be redirected to our controller's create method when validation fails, allowing us to display the error messages in the view: ... <!-- /resources/views/post/create.blade.php --> <h1>Create Post</h1> @if ($errors->any()) <div class="alert alert-danger"> <ul> @foreach ($errors->all() as $error) <li>{{ $error }}</li> @endforeach </ul> </div> @endif <!-- Create Post Form -->
🌐
Chart.js
chartjs.org › docs › latest › samples › other-charts › doughnut.html
Doughnut | Chart.js
const DATA_COUNT = 5; const NUMBER_CFG = {count: DATA_COUNT, min: 0, max: 100}; const data = { labels: ['Red', 'Orange', 'Yellow', 'Green', 'Blue'], datasets: [ { label: 'Dataset 1', data: Utils.numbers(NUMBER_CFG), backgroundColor: Object.values(Utils.CHART_COLORS), } ] }; const actions = [ { name: 'Randomize', handler(chart) { chart.data.datasets.forEach(dataset => { dataset.data = Utils.numbers({count: chart.data.labels.length, min: 0, max: 100}); }); chart.update(); } }, { name: 'Add Dataset', handler(chart) { const data = chart.data; const newDataset = { label: 'Dataset ' + (data.datasets
Find elsewhere
🌐
Mastering JS
masteringjs.io › tutorials › fundamentals › foreach-object
Iterating Through an Object with `forEach()` - Mastering JS
May 29, 2020 - You can use `forEach()` to iterate over a JavaScript object using `Object.key()`, `Object.values()`, and `Object.entries()`. Here's what you need to know.
🌐
React
react.dev › learn › thinking-in-react
Thinking in React – React
function ProductCategoryRow({ category }) { return ( <tr> <th colSpan="2"> {category} </th> </tr> ); } function ProductRow({ product }) { const name = product.stocked ? product.name : <span style={{ color: 'red' }}> {product.name} </span>; return ( <tr> <td>{name}</td> <td>{product.price}</td> </tr> ); } function ProductTable({ products }) { const rows = []; let lastCategory = null; products.forEach((product) => { if (product.category !== lastCategory) { rows.push( <ProductCategoryRow category={product.category} key={product.category} /> ); } rows.push( <ProductRow product={product} key={product.name} /> ); lastCategory = product.category; }); return ( <table> <thead> <tr> <th>Name</th> <th>Price</th> </tr> </thead> <tbody>{rows}</tbody> </table> ); } function SearchBar() { return ( <form> <input type="text" placeholder="Search..."
🌐
GeeksforGeeks
geeksforgeeks.org › javascript › how-to-use-foreach-with-an-array-of-objects-in-javascript
How to use forEach with an Array of Objects in JavaScript ? - GeeksforGeeks
June 10, 2024 - Using the forEach() method with an array of objects in JavaScript is essential for iterating over collections and performing operations on each object.
🌐
Mastering JS
masteringjs.io › tutorials › fundamentals › foreach-key-value
How to Use forEach() with Key Value Pairs - Mastering JS
After that, you can then use forEach() to iterate through the keys, values, or entries: const obj = { name: 'Jean-Luc Picard', rank: 'Captain' }; // Prints "name Jean-Luc Picard" followed by "rank Captain" Object.keys(obj).forEach(key => { console.log(key, obj[key]); });
🌐
MDN Web Docs
developer.mozilla.org › en-US › docs › Web › JavaScript › Reference › Global_Objects › Object › keys
Object.keys() - JavaScript | MDN
Object.keys() returns an array whose elements are strings corresponding to the enumerable string-keyed property names found directly upon object. This is the same as iterating with a for...in loop, except that a for...in loop enumerates properties in the prototype chain as well.
🌐
Latenode
latenode.com › home › blog › development & programming › javascript for automation › how to iterate over a javascript object?
How to Iterate Over a JavaScript Object? - Latenode Blog
February 12, 2026 - The for...in loop is a traditional way to iterate over over object javascript. It is simple and widely supported but requires an additional hasOwnProperty() check to avoid iterating over inherited properties. The Object.entries() method, combined with map() or forEach(), provides a concise way to access both keys and values of an object.
🌐
Medium
medium.com › @louistrinh › iterating-through-javascript-objects-and-arrays-for-foreach-and-beyond-e9e6ce5376d3
Iterating Through JavaScript Objects and Arrays: for, forEach, and Beyond | by Louis Trinh | Medium
May 10, 2024 - const person = { name: "Alice", age: 30 }; Object.keys(person).forEach(key => { console.log(key, person[key]); // Output: name Alice, age 30 });
🌐
Useaxentix
useaxentix.com › blog › javascript › how-to-use-foreach-for-object-in-javascript
How to Use forEach for Object in JavaScript: Complete Guide
October 10, 2025 - JavaScript's forEach() method is a powerful array method that allows you to iterate over array elements, but it cannot be used directly on objects.
🌐
Altcademy
altcademy.com › blog › how-to-loop-through-object-in-javascript
How to loop through object in JavaScript
June 9, 2023 - Now that we understand what an object is, let's learn how to loop through its properties. Looping through an object means iterating over its properties one by one, usually to perform some operation on the property values or keys. There are several ways to do this in JavaScript, and we'll explore them one by one.
🌐
freeCodeCamp
forum.freecodecamp.org › javascript
Use of .Object in this forEach loop example - JavaScript - The freeCodeCamp Forum
January 24, 2019 - json.forEach(function(val) { var keys = Object.keys(val); html += "<div class = 'cat'>"; keys.forEach(function(key) { html += "<strong>" + key + "</strong> " + val[key] + "</br>;"; }); html += "</div><br>";…
🌐
freeCodeCamp
freecodecamp.org › news › javascript-foreach-how-to-loop-through-an-array-in-js
JavaScript forEach – How to Loop Through an Array in JS
July 6, 2020 - The forEach method passes a callback function for each element of an array together with the following parameters: Current Value (required) - The value of the current array element · Index (optional) - The current element's index number · Array (optional) - The array object to which the current element belongs
🌐
GeeksforGeeks
geeksforgeeks.org › typescript › how-to-iterate-over-object-properties-in-typescript
How to Iterate Over Object Properties in TypeScript - GeeksforGeeks
October 1, 2024 - Object.keys(object).forEach(key => { console.log(`${key}: ${object[key]}`); }); Example: In this example, we used assertion as Array<keyof typeof user> so that TypeScript knows that the keys are valid for the user object. JavaScript ·