Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
A concise function that serializes an array, regardless of the depth of its contents.
JavaScript
branch: master

Fetching latest commit…

Cannot retrieve the latest commit at this time

Failed to load latest commit information.
README.md
better-array-to-string.js
package.json

README.md

betterArrayToString

You know what I'd love to do? Output this array in useful way!

var a = ['the nina', 'the pinta', 'the santa maria', 1, 2, 3, { a : 'boats' }, { b : 'hoes' }];
console.log( a.toString() );
// the nina,the pinta,the santa maria,1,2,3,[object Object],[object Object]

Wait, what the hell? Which are the strings? Which are the numbers? And what the hell am I supposed to do with [object Object]?

Well, I got your ass on two of those problems.

Usage

Install it

npm install better-array-to-string

Use the shit out of it

Array.prototype.toString = require('better-array-to-string');
// OH NOO THE WORLD IS ENDING

var a = ['the nina', 'the pinta', 'the santa maria', 1, 2, 3, { a : 'boats' }, { b : 'hoes' }];
console.log( a.toString() );
// [ "the nina", "the pinta", "the santa maria", 1, 2, 3, [object Object], [object Object] ]
// OH WAIT NO IT'S NOT ENDING! I ACTUALLY HAVE A USEFUL FUNCTION NOW! I CAN SEE EVERYTHINGGGGGGGGGG!!!1111

Nice... except... that damn object. What's up with that shit?

Come on. Like I don't have your ass on that too.

betterObjectToString

I don't care

  • You're probably like, "UHHHHH YOU SHOULDN'T BE WRECKING FUNCTIONS YOU DON'T OWN." Whatever. If this breaks something, someone was doing it wrong.
  • I don't care about you, unless you give me money.
  • I don't care about maintainability. I did, but then this useless fucking method existed, so then I stopped caring and made it useful.
  • I don't care about your suggestions unless they're in the form of a pull request. Then we can have a lively conversation about them before I savagely pull them.
Something went wrong with that request. Please try again.