17 private links
Think of it like you're just calling JavaScript functions. You can't put a for
loop inside a function call:
return tbody(
for (var i = 0; i < numrows; i++) {
ObjectRow()
}
)
But you can make an array, and then pass that in:
var rows = [];
for (var i = 0; i < numrows; i++) {
rows.push(ObjectRow());
}
return tbody(rows);
You can use basically the same structure when working with JSX:
var rows = [];
for (var i = 0; i < numrows; i++) {
// note: we add a key prop here to allow react to uniquely identify each
// element in this array. see: https://reactjs.org/docs/lists-and-keys.html
rows.push(<ObjectRow key={i} />);
}
return <tbody>{rows}</tbody>;
Incidentally, my JavaScript example is almost exactly what that example of JSX transforms into. Play around with Babel REPL to get a feel for how JSX works.
Catalog of React Components & Libraries
$ git branch new-branch-name origin/old-branch-name
$ git push origin --set-upstream new-branch-name
$ git push origin :old-branch-name
It is now available with the latest PM2 version:
{
apps : [{
name : 'API',
script : 'api.js',
interpreter : 'node@6.9.1'
}]
}
https://github.com/Unitech/pm2/blob/master/test/fixtures/nvm-node-version/ecosystem.json#L12
A new kind of emoji set. Mutant Standard breaks the traditional conventions of emoji to give you more inclusivity, choice and freedom.
const result = _.map({a: 1, b: 2}, function(value, key) {
return value + key;
});
Since nobody has added the obvious solution yet which works fine for two comparisons, I'll offer it:
if (foobar == foo || foobar == bar) {
//do something
}
And, if you have lots of values, then I'd suggest making a Set as this makes very clean and simple comparison code and it's fast at runtime:
// pre-construct the Set
var tSet = new Set([foo, bar, test1, test2, test3]);
// test the Set at runtime
if (tSet.has(foobar)) {
// do something
}
For pre-ES6, you can get a Set polyfill of which there are many. One is described in this other answer.
Practical advice for managing Imposter Syndrome.
Mike Bostock’s Block 3808218
Jane Pong’s Block 9b9e606e9876e34385cc4aeab188ed73
The missing link between spreadsheets and data visualization.