r/learnjavascript • • Apr 29 '19

I made a Javascript cheat sheet

I don't know if it can help someone else besides me, but, here it is the Github Project and the web site I made.

Contributions and feedback are always welcome.

Edit: fixed the repo link.

254 Upvotes

30 comments sorted by

12

u/psiph Apr 29 '19 edited Apr 29 '19

This is excellent! Very well done! I'm not a beginner, but I'll still use this!

Maybe make it a separate repo from the Python one? That'd make it easier for me to star, as I'd know why I saved it when coming back to it.

Edit: Nice, the GitHub link is updated now!

3

u/wilfredinni Apr 29 '19

It is a completely different repo, I just used a subdomain from the pythoncheatsheet.org

Edit: linked the wrong repo. Fixed

3

u/Time_Terminal Apr 29 '19

Couple things I'd add:

  • Immutability (maybe right after var/let/const)

  • Array destructuring

1

u/karatetoes Apr 30 '19

Array destructuring is just the right practice of deleting the whole array object to free up memory right?

3

u/Fingerbob73 Apr 29 '19

​ \f from feed

(It's 'form')

Otherwise good.

4

u/wilfredinni Apr 29 '19

from

feed

Your right, I'll fix it shortly, thank you.

5

u/MoTTs_ Apr 29 '19 edited Apr 30 '19

The class syntax is just a syntax, and not a full-fledged class based implementation of object oriented paradigm, unlike in languages like Java, or Python, or Ruby etc.

Surprisingly, the implementation of classes in JavaScript, Python, and Ruby are all actually very similar, where classes are themselves objects, and inheritance from instance to class to superclass is done by delegation. Python and JS classes side-by-side.

5

u/serious_case_of_derp Apr 29 '19

Maybe change this under ES6 Arrow Functions?

 // to pass a single parameter to an arrow function
const doubler = item => item * 2;

// to pass multiple parameters to an arrow function - parenthesis are needed 
const doubler = (item1,item2) => item1 * item2;

1

u/Aka_Erus Apr 29 '19

I don't see it, where is the mistake ?

Is it calling " doubler" the second function ?

5

u/Time_Terminal Apr 29 '19

It's not a mistake but an addition they are proposing.

OP doesn't have separate examples for passing 1 variable or more than one variable in arrow functions. u/serious_case_of_derp is saying this should be added.

2

u/Aka_Erus Apr 29 '19

Thanks, I should have checked the website to see the original code.

2

u/DeepSpaceGalileo Apr 30 '19

In fact to cover all cases they should have 0, 1 and >1 args.

2

u/Time_Terminal Apr 30 '19

Good point.

1

u/[deleted] Apr 29 '19

I think you messed up. The GitHub Project is linked to a Python Cheat Sheet.

2

u/wilfredinni Apr 29 '19

Fixed it!

1

u/[deleted] Apr 29 '19

I still can't find the JavaScript link. It takes me to the GitHub repo. Then on the repos site it points to a python cheat sheet website.

1

u/wilfredinni Apr 29 '19

you mean the link to the repo? https://github.com/wilfredinni/javascript-cheatsheet or the webpage?

1

u/[deleted] Apr 29 '19

Never mind i was clicking the wrong link

3

u/HarmonicAscendant Apr 29 '19

The lessons in this section handle non-browser features. import won't work on a browser directly. However, we can use various tools to create code out of this to make it work in browser.

Cool cheatsheet, but this is plain wrong. You just add type="module" in the HTML. I have been happily using it for over a year, sod IE, all that nonsense is history.

https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/import

Make sure you add '.js' at the end of the import. Import will work well in Node 12 now too with 'experimental modules' enabled:

https://medium.com/@nodejs/announcing-a-new-experimental-modules-1be8d2d6c2ff

or just use https://github.com/standard-things/esm

3

u/r3jjs Apr 30 '19

For the most part, it looks good.

One thing do -- please use another example for String.prototype.split. Using the '' string separate a string into characters only works for strings that it into the Unicode Basic Multilingual plane. Higher-order characters, which longer than two bytes, gets ripped apart.

String.prototype.length has a similar issue.

(Array.from(...) is a good way to split up strings.

https://mathiasbynens.be/notes/javascript-unicode

2

u/Kapsize Apr 29 '19

This looks like a wonderful resource - thanks for sharing!

2

u/asg-br Apr 29 '19

that's great! Thanks for sharing :)

2

u/d3vCr0w Apr 29 '19

Very useful, just by taking a quick look I already found stuff I didn't know about, thank you!

2

u/weavermjordan Apr 29 '19

thanks! awesome

2

u/Apple61752 Apr 29 '19

Anything for Java or c++?

2

u/TattooedBear Apr 29 '19

Great work. Thank you for sharing.

2

u/cejno May 01 '19

It’s wonderful.

1

u/coolrivers May 09 '19

well done. I needed this review

1

u/aceeeric Aug 08 '19

Thanks Wilfred, this is really helpful