Skip to content

Commit

Permalink
Don't mention objects, but show array wackiness and explain why it's …
Browse files Browse the repository at this point in the history
…important to know about
  • Loading branch information
pletcher committed Feb 25, 2016
1 parent c327905 commit 1604655
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -184,13 +184,13 @@ letters.forEach(function(letter, index) {

## Array Wackiness

It's important to remember that arrays in JavaScript are really just special
kinds of `Object`s. You can assign properties to them:
It's important to remember that arrays in JavaScript are kind of wonky. You can
assign properties to them:

```js
var array = [1, 2, 3];

array.myProperty = "I'm an object!";
array.myProperty = "I'm a property!";

```

Expand All @@ -202,12 +202,16 @@ array;

// Where did our property go?
array.myProperty;
// "I'm an object!";
// "I'm a property!";

array.length;
// 3 - Would you have expected 3 or 4?
```

We don't tend to do these kinds of things on purpose, but it's important to be
aware that they can happen so that you have a good sense of where to look
if/when strange bugs start to appear.

## Resources

* [MDN - Arrays](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array)
Expand Down

0 comments on commit 1604655

Please sign in to comment.