Skip to content

Added array item stacking #144

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 2 commits into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 19 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Airbnb JavaScript Style Guide() {
# Liftopia JavaScript Style Guide() {

*A mostly reasonable approach to JavaScript*

Expand Down Expand Up @@ -121,17 +121,29 @@

## <a name='arrays'>Arrays</a>

- Use the literal syntax for array creation
- Use the literal syntax for array creation

```javascript
// bad
var items = new Array();

// good
var items = [];
var items = [];
```

- If you don't know array length use Array#push.
- Declare each new array item on a new line

```javascript
// bad
var items = ['foo', 'bar', 'bam']

// good
var items = ['foo',
'bar',
'bam']
```


- If you don't know array length use Array#push.

```javascript
var someStack = [];
Expand All @@ -144,7 +156,7 @@
someStack.push('abracadabra');
```

- When you need to copy an array use Array#slice. [jsPerf](http://jsperf.com/converting-arguments-to-an-array/7)
- When you need to copy an array use Array#slice. [jsPerf](http://jsperf.com/converting-arguments-to-an-array/7)

```javascript
var len = items.length,
Expand All @@ -160,7 +172,7 @@
itemsCopy = items.slice();
```

- To convert an array-like object to an array, use Array#slice.
- To convert an array-like object to an array, use Array#slice.

```javascript
function trigger() {
Expand Down