Skip to content

Commit

Permalink
Clarifying the default for join() is ",". Fixes #214 - Closes #268
Browse files Browse the repository at this point in the history
  • Loading branch information
Markus Amalthea Magnuson authored and gnarf committed Feb 27, 2013
1 parent ac93e83 commit e1bf5ff
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions page/javascript-101/arrays.md
Expand Up @@ -106,16 +106,22 @@ var wholeArray = myArray.concat( myOtherArray );

### `.join`

`.join` creates a string representation of the array. Its parameter is a string that works as a separator between elements (default separator is a comma):
`.join` creates a string representation of an array by joining all of its elements using a separator string. If no separator is supplied (e.g. `.join` is called without arguments) the array will be joined using a comma:

```
// Joining elements
var myArray = [ "hello", "world", "!" ];
console.log( myArray.join(" ") ); // "hello world !";
// The default separator is a comma
console.log( myArray.join() ); // "hello,world,!"
console.log( myArray.join("") ); // "helloworld!"
// Any string can be used as separator...
console.log( myArray.join(" ") ); // "hello world !";
console.log( myArray.join("!!") ); // "hello!!world!!!";
// ...including an empty one
console.log( myArray.join("") ); // "helloworld!"
```

### `.pop`
Expand Down

0 comments on commit e1bf5ff

Please sign in to comment.