Live data from Hacker News

Cheatsheet for the modern JavaScript

github.com

21–30 of 37 posts

Re: Cheatsheet for the modern JavaScript

#21

Earlier quoted context omitted.

Thanks 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…

Why are you being downvoted for this? AFAICT these are low-res previews of high-quality PDF cheat sheets you can buy.

I 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.

Re: Cheatsheet for the modern JavaScript

#22
Rules 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)

Re: Cheatsheet for the modern JavaScript

#23

Ugh, 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 sto…

I get your point, but I'm not sure I share your cynicism. For instance, a "constant" container with mutable contents is the first example given in Practical Common Lisp [0]: (defvar *db* nil) (defun add-record (cd) (push cd *db*)) (defun make-cd (title artist rating ripped) (list :title title :artist artist :rating rating :ripped ripped)) (add-record (make-cd "Roses" "Kathy Mattea" 7 t)) If you're concerned about thi…

My Lisp is a bit rusty, but I think actual constants are written +with-pluses+, whereas * the-stars * indicate global variables. And that database isn't just internally mutable, sometimes it's replaced completely [0]:

  (defun load-db (filename)
    (with-open-file (in filename)
      (with-standard-io-syntax
        (setf *db* (read in)))))
[0]: http://www.gigamonkeys.com/book/practical-a-simple-database....

Re: Cheatsheet for the modern JavaScript

#24

This 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.

Thank you. For comparison, these are real cheatsheets: * https://zeroturnaround.com/wp-content/uploads/2017/03/regex-... * https://rumorscity.com/wp-content/uploads/2014/08/10-Best-VI... * https://wch.github.io/latexsheet/latexsheet-1.png

High res versions:

Regex: https://i.imgur.com/f47LvfU.png

Vim: https://i.imgur.com/YLInLlY.png

Latex: no hi res version but PDF + 2nd page! here

https://wch.github.io/latexsheet/

Re: Cheatsheet for the modern JavaScript

#25

Earlier quoted context omitted.

Thank you. For comparison, these are real cheatsheets: * https://zeroturnaround.com/wp-content/uploads/2017/03/regex-... * https://rumorscity.com/wp-content/uploads/2014/08/10-Best-VI... * https://wch.github.io/latexsheet/latexsheet-1.png

Thanks 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…

High res versions:

Regex: https://i.imgur.com/f47LvfU.png

Vim: https://i.imgur.com/YLInLlY.png

Latex: no hi res version but PDF + 2nd page! here

https://wch.github.io/latexsheet/

Re: Cheatsheet for the modern JavaScript

#27

Ugh, 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 sto…

It's unfortunate that you take such an inflammitory tone when you're so completely incorrect. They are constant, end of story.

Re: Cheatsheet for the modern JavaScript

#28
post #13

Ugh, 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 sto…

But 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}; //…

Let 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".

Re: Cheatsheet for the modern JavaScript

#29
post #5

I 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.

`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, 5, 5, 5, 5
    }

    for (let i = 0; i  0, 1, 2, 3, 4
    }

Re: Cheatsheet for the modern JavaScript

#30
post #15

Earlier quoted context omitted.

Thanks 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…

Summary? Overview?

Judging 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"

Post reply on HN