Welcome to JS Bin
Load cached copy from
 
<!DOCTYPE html>
<html>
<head>
  <meta charset="utf-8">
  <title>JS Bin</title>
</head>
<body>
</body>
</html>
 
var a = [
    [
        [1, 2, 3],
        [4, 5, 6]
    ],
    [
        [7, 8, 9],
        [10, 11]
    ], {
        x: 12,
        y: [13, 14, {
            x: 15,
            y: 16
        }]
    }
];
var handlers = [
    e => console.log('f1: ' + e),
    e => console.log('  f2: ' + e),
    e => console.log('    f3: ' + e),
    e => console.log('       f4: ' + e),
];
function iterate(e, l) {
    if (typeof handlers[l] == 'function') handlers[l](e);
    if (typeof e == 'object') Object.keys(e).forEach(i => iterate(e[i], l + 1));
}
iterate(a, 0);
Output

You can jump to the latest bin by adding /latest to your URL

Dismiss x