r/javascript • • Mar 17 '15

Javascript API Cheat Sheet

http://overapi.com/javascript/
162 Upvotes

18 comments sorted by

33

u/PENIS-PENIS Mar 17 '15

3

u/Poop_is_Food Mar 17 '15

sweet jesus

1

u/shriek Mar 18 '15

not-so-secret-tip:- Install this as a chrome app and ctrl+L type devdocs hit taband type #q=js array for eg. given that you have javascript enabled.

1

u/omegote Mar 17 '15

Wow, just wow. You're the real MVP.

1

u/hannyajin Mar 18 '15

Fantastic link!

1

u/dirtymuckraker Mar 18 '15

errmygod, T_T. thank you.

12

u/Archenoth with(RegExp) eval($_); Mar 17 '15 edited Mar 17 '15

Aw, it's missing the functional Array functions like map, filter, reduce, etc...

They are important because they can be applied to element results, strings, objects with a .length, Regex results, or anything that looks like a collecttion of some sort for some incredibly terse and functional code.

For example, if you want to generate JSON from a querySelectorAll, you can just map over the results and return object literals in the anonymous function...

So, the following would return server-ready JSON:

JSON.stringify(Array.prototype.map.call(document.querySelectorAll(".row"), function(row){
  return {
    'name': row.querySelector('.name').value,
    'value': row.querySelector('.value').value
  };
}));

I'd argue that the Array prototype functions are some of the most important in JavaScript.

4

u/jcready __proto__ Mar 17 '15

Shouldn't that be Array.prototype.map.call?

1

u/Archenoth with(RegExp) eval($_); Mar 17 '15

Yes, it should... Whoops.
(You can probably tell I just typed that up on the spot.)

1

u/AaronOpfer Mar 18 '15

if you want to generate JSON from a querySelectorAll

I really hope you don't do this a lot.

1

u/Archenoth with(RegExp) eval($_); Mar 18 '15

Oh yeah? Why not?

It may not be something you should do daily, but it can be useful to implement something like user-custom fields with nearly zero code or overhead.

3

u/MrBester Mar 18 '15

Or a polyfill for FormData , perhaps...

3

u/hadees Mar 17 '15

the colors hurt my eyes

1

u/ForScale Mar 17 '15

So... this seems awesome! Thanks!!

1

u/[deleted] Mar 17 '15

This is really great. When I click one of those links, there are several places I could imagine ending up developer.mozilla.org, WebPlatform.org, w3c.org or caniuse.com. It would be cool if I could get to some of these other sources too. Not that this tool isn't badass already.

Also, have you heard of Dash documentation app for Mac or Zeal documentation app for windows?

1

u/rDr4g0n Mar 17 '15

Dunno if this is kind what you meant: devdocs.io

It combines docs from all over the web into one ui.

1

u/owenr88 Mar 17 '15

Looks great! One suggestion, how about collapsing/hiding the greyed out items after you've searched? Similar to NameMesh