View array-chunker.js
This file contains 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
chunkArray(arr, size) { | |
let arrLength = arr.length, | |
mainLength = Math.ceil(arrLength/size), | |
mainArray = [], | |
chunkArray = [] | |
for(var i=1; i<=arrLength; i++) { | |
if (i % size === 1) { | |
// starting new chunk -> clear chunk array and push | |
chunkArray = [] |
View cached-for-loop.js
This file contains 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
let items = [ | |
//unknown number of items | |
] | |
// normal for loop | |
// here items.length is calculated each time the loop cycles | |
for (let i=0; i<items.length; i++) { | |
// inside for | |
} |
View tr-class-function-table.jsx
This file contains 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
function rowClassNameFormat(row, rowIdx) { | |
// row is whole row object | |
// rowIdx is index of row | |
return rowIdx % 2 === 0 ? 'td-column-function-even-example' : 'td-column-function-odd-example'; | |
} | |
class TrClassStringTable extends React.Component { | |
render() { | |
return ( | |
<BootstrapTable data={ products } trClassName={this.rowClassNameFormat}> |