7 ms·
Cheatsheet for the modern JavaScript
- deleted 9y ago[deleted]
- interfixus 9y agoThis is probably a fine resource. Can't really judge it - I avoid JavaScript to the extend humanly possible. But please - could someone end the devaluation of the word cheatsheet. A cheatsheet should be just that - a sheet of paper or its digital equivalent, with a few short, clear notes of essentials. Not a rambling document. Not something with a table of contents.
- yoz-y 9y agoAgree. I was expecting something that one could print on maximum two A4 pages. This here is a rather long pamphlet.
- ComputerGuru 9y agoThank you. For comparison, these are real cheatsheets: * https://zeroturnaround.com/wp-content/uploads/2017/03/regex-cheat-sheet-rebellabs-768x543.png https://zeroturnaround.com/wp-content/uploads/2017/03/regex-... * https://rumorscity.com/wp-content/uploads/2014/08/10-Best-VIM-Cheat-Sheet-02.jpg https://rumorscity.com/wp-content/uploads/2014/08/10-Best-VI... * https://wch.github.io/latexsheet/latexsheet-1.png https://wch.github.io/latexsheet/latexsheet-1.png
- Stratoscope 9y agoThanks for the cheatsheet examples. They bring back fond memories of the laminated cheatsheets I used to buy at the bookstore. But it's been a long time since I used one of those; now I just want everything in digital form to keep my backpack light. It was interesting that these are all bitmap image files at a rather low resolution. The text is so blurry on all of them! It made me wonder: do people actually use these kinds of image cheatsheets? They wouldn't print well, and zooming in on screen just gives blurry text. My old laminated sheets had crisp high-quality printed text. It would be different if they were in a vector format, of course. But since I'm not printing them anyway, the traditional cheatsheet is no longer a useful format for me. I much prefer a short document like the OP's "cheatsheet" with legible text that I can scroll through on any device without having to zoom in and pan around. I suppose one could object to the "sheet" part, since you can't print a document like this on a single sheet of letter or A4 paper. But that doesn't bother me at all: I started my programming career on Teletype machines that used roll paper, and we routinely printed out cheatsheets of varying length. There was no set height to a sheet: it ended wherever you tore it off the roll. What would be a better name for a document like this that serves the purpose of a traditional cheatsheet but is in a format more suited for digital reading? Maybe "A short guide to ..."? (Updated with more stories)
- pavlov 9y agoSummary? Overview?
- pavlov 9y agoJudging by the downvotes, I think that post was misinterpreted. I was suggesting that the word "cheatsheet" could be replaced by "summary" or "overview". E.g. "An overview of modern JavaScript" or "Modern JavaScript - Executive Summary"
- deleted 9y ago[deleted]
- nerdponx 9y agoWhy are you being downvoted for this? AFAICT these are low-res previews of high-quality PDF cheat sheets you can buy.
- Stratoscope 9y agoI think people downvoted version 1 of my comment, which was less interesting and more cranky. But the downvotes were helpful; they gave me an excuse to make it more friendly and add a relevant story. :-) I should have guessed that these were just low-res previews: I read too much into the comment that they were real cheatsheets. Even with high-quality vector text, though, I wouldn't find them useful because of the layout. It's great if you print them, but if you like to have everything onscreen, a scrolling document is easier to read.
- andai 9y agoHigh res versions: Regex: https://i.imgur.com/f47LvfU.png https://i.imgur.com/f47LvfU.png Vim: https://i.imgur.com/YLInLlY.png https://i.imgur.com/YLInLlY.png Latex: no hi res version but PDF + 2nd page! here https://wch.github.io/latexsheet/ https://wch.github.io/latexsheet/
- andai 9y agoHigh res versions: Regex: https://i.imgur.com/f47LvfU.png https://i.imgur.com/f47LvfU.png Vim: https://i.imgur.com/YLInLlY.png https://i.imgur.com/YLInLlY.png Latex: no hi res version but PDF + 2nd page! here https://wch.github.io/latexsheet/ https://wch.github.io/latexsheet/
- ComputerGuru 9y agoThanks but due to imgur’s recent update these are even lower resolution than the quick finds in my original post (on mobile). I’ll post full-size links when I get to a PC.
- deleted 9y ago[deleted]
- dahart 9y agoFor ES6, I really like this one: http://es6-features.org/ http://es6-features.org/ Not a cheatsheet per-se (nor sold as one), but at least they keep it mostly on one page, it's closer to a cheatsheet and better than a long document.
- masterleep 9y agoNicely done.
- jlebrech 9y agoI usually just do just enough javascript, but didn't know the difference between let and var, not it makes sense. the explanation of reduce made sense too.
- Fifer82 9y agoI always use `const` unless i can't otherwise `let`. There is no place for `var` although everyone has an opinion this has always worked for me.
- Mateon1 9y ago`let` is block scoped, while `var` is function scoped. Essentially: function do_something() { if (true) { var x = 42; let y = 42; } console.log(x); // 42 console.log(y); // Reference error: y is not defined } It's extremely useful in for loops: for (var i = 0; i < 5; i++) { setTimeout(function () { console.log(i); }); // => 5, 5, 5, 5, 5 } for (let i = 0; i < 5; i++) { setTimeout(function () { console.log(i); }); // => 0, 1, 2, 3, 4 }
- jlebrech 9y agothat makes a lot of sense, I used to just make a brand new unique variable for loops
- EternalData 9y agoHandy resource -- but like somebody else commented, probably better called a summary of modern JavaScript than a cheatsheet.
- asar 9y agoVery helpful and great explanations. To me Airbnb's JS styleguide was also very helpful, which showcases best practices and lots of examples. https://github.com/airbnb/javascript https://github.com/airbnb/javascript
- narsil 9y agoI've also found the BabelJS "Learn ES2015" page valuable as a cheat sheet and usually have it open while working with ES2015+: https://babeljs.io/learn-es2015/ https://babeljs.io/learn-es2015/
- mattmanser 9y agoUgh, why can't JavaScript programmers learn from others languages first? Making all your variables const is just going to confuse most people WHEN THEY'RE NOT CONSTANT. Stop with the const spam already, you just look like dicks. I am waiting for the articles in 3 years time, "const isn't constant" as the JavaScript community tediously explain to each other ref. vs value types like it's the 1990s. Just use let and stop confusing people.
- benjaminsuch 9y agoIf the value of that "variable" is not supposed to be changed, I use const.
- K0nserv 9y agoBut the values are const? You just need to understand the implication of const in javascript. Why would you choose to weaken the communication in your code by choosing `let` over `const` when you have no intention of reassign the value? `let` would just confuse the reader as they'd start anticipating the reassignment. Compare: ``` // A variable containing an object that will not be reassigned const a = { foo: 10}; // This is still valid a.foo = 10; ``` vs ``` // A variable containing an object that might be reassigned. let a = { foo: 10}; // This is still valid a.foo = 10; ``` The first example says more about your intent and throwing that information away is a bad idea.
- mbrock 9y agoLet is a much nicer keyword though. It just reads better. I almost never use variable mutation in JS, and I use let almost everywhere. That lets me use the let/const distinction in a way that to me seems even more informative, namely to distinguish actual constants like "site base URL" or "pi".
- vectorpush 9y agoIt's unfortunate that you take such an inflammitory tone when you're so completely incorrect. They are constant, end of story.
- 9y ago
- baron816 9y agoRules for this in JS from top to bottom in priority: 1. The function was called with 'new' 2. The function was called with 'call' or 'apply' specifying an explicit this 3. The function was called via a containing/owning object (context) 4. DEFAUL: global object (expect strict mode--undefined)
- ghusbands 9y agoYou missed out Function.prototype.bind
- deleted 9y ago[deleted]
- rafat69ahmed 9y agotnx