Last active
November 28, 2016 07:11
-
-
Save JanneSalokoski/654de3e14fb058c2ca8ddaf3af5b27ab to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Original implementation using Object.values | |
var cols = Object.values(this.data); | |
for (var i = 0; i < cols.length; i++) | |
{ | |
console.log(Object.values(this.data[i])); | |
new this.Row(Object.values(this.data[i])); | |
} | |
// Newer implementation using Object.entries | |
for (var i = 0; i < Object.entries(this.data).length; i++) | |
{ | |
var row = []; | |
for (var j = 0; j < Object.keys(this.data[0]).length; j++) | |
{ | |
row.push(Object.entries(this.data)[i][1][Object.keys(this.data[0])[j]]); | |
} | |
new this.Row(row); | |
} | |
// Newest implementation using for...in loops | |
for (var i in this.data) | |
{ | |
var row = []; | |
for (var j in this.data[i]) | |
{ | |
row.push(this.data[i][j]); | |
} | |
new this.Row(row); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment