javascript
javascript copied to clipboard
"#arrays--bracket-newline" which one is better ?
In the guide (I mean README.md of airbnb/javascript), there is an example of arrays-bracket-newline.
- 4.8 Use line breaks after open and before close array brackets if an array has multiple lines
// bad
const arr = [
[0, 1], [2, 3], [4, 5],
];
const objectInArray = [{
id: 1,
}, {
id: 2,
}];
const numberInArray = [
1, 2,
];
// good
const arr = [[0, 1], [2, 3], [4, 5]];
const objectInArray = [
{
id: 1,
},
{
id: 2,
},
];
const numberInArray = [
1,
2,
];
Here is an example for "arr".
// good
const arr = [[0, 1], [2, 3], [4, 5]];
But I think this is better.
const arr = [
[0, 1],
[2, 3],
[4, 5]
];
I just wanna talk about with everyone who interest in convention. Let's discuss!
https://github.com/airbnb/javascript#arrays--bracket-newline
This is good as it is.