1//Array
2$.each( arr, function( index, value ){
3 sum += value;
4});
5
6//Object
7$.each( obj, function( key, value ) {
8 sum += value;
9});
1var obj = {
2 "flammable": "inflammable",
3 "duh": "no duh"
4};
5$.each( obj, function( key, value ) {
6 alert( key + ": " + value );
7});
8
1// OBJECTS
2const obj = {
3 one: 1,
4 two: 2,
5 three: 3,
6 four: 4,
7 five: 5
8};
9
10$.each(obj, function(key, value) {
11 console.log(value);
12});
13
14// Outputs: 1 2 3 4 5
15