Live data from Hacker News

JavaScript fundamentals before learning React

robinwieruch.de

1–10 of 72 posts

Re: JavaScript fundamentals before learning React

#2
This article has a lot to offer a JS + React beginner so it feels lame to reply to some tiny part of it, but this bit is a constant error propogated in the ecosystem:

> Even though it is possible to mutate the inner properties of objects and arrays when using const, the variable declaration shows the intent of keeping the variable immutable though.

let and const only control mutability of the reference. They say nothing of the value mutability. const then can only be a signal that you are not reassigning to the identifier.

const is still useful as a default of course since reassignment is generally the exception.

Maybe this is what they meant but the language used made it seem otherwise.

Re: JavaScript fundamentals before learning React

#3

This article has a lot to offer a JS + React beginner so it feels lame to reply to some tiny part of it, but this bit is a constant error propogated in the ecosystem: > Even though it is possible to mutate the inner properties of objects and arrays when using const, the variable declaration shows the intent of keeping the variable immutable though. let and const only control mutability of the reference. They say noth…

Beginners don't know about references. What you say is exactly what the author meant.

Re: JavaScript fundamentals before learning React

#4
post #3

This article has a lot to offer a JS + React beginner so it feels lame to reply to some tiny part of it, but this bit is a constant error propogated in the ecosystem: > Even though it is possible to mutate the inner properties of objects and arrays when using const, the variable declaration shows the intent of keeping the variable immutable though. let and const only control mutability of the reference. They say noth…

Beginners don't know about references. What you say is exactly what the author meant.

Author here {: Yes, what you are saying here is what I meant. I didn't want to mix in the whole topic around "passing by value or reference" in this short teaser.

Hi Swizec :wave: :)

Re: JavaScript fundamentals before learning React

#5
post #3

This article has a lot to offer a JS + React beginner so it feels lame to reply to some tiny part of it, but this bit is a constant error propogated in the ecosystem: > Even though it is possible to mutate the inner properties of objects and arrays when using const, the variable declaration shows the intent of keeping the variable immutable though. let and const only control mutability of the reference. They say noth…

Beginners don't know about references. What you say is exactly what the author meant.

[deleted]

Re: JavaScript fundamentals before learning React

#6
post #4
post #3

Earlier quoted context omitted.

Beginners don't know about references. What you say is exactly what the author meant.

Author here {: Yes, what you are saying here is what I meant. I didn't want to mix in the whole topic around "passing by value or reference" in this short teaser. Hi Swizec :wave: :)

Hi, Robin.

Then you may want to say that `const` guarantees that the name will remain bound to that object.

The great-GP is correct in that `const` has nothing to do with immutability besides that. It doesn't necessarily conveys an intent of inner immutability. It just states that whatever is in the variable will stay there until it goes out of scope.

Using `const` whenever possible is good advice, off course.

Re: JavaScript fundamentals before learning React

#7
post #6
post #4

Earlier quoted context omitted.

Author here {: Yes, what you are saying here is what I meant. I didn't want to mix in the whole topic around "passing by value or reference" in this short teaser. Hi Swizec :wave: :)

Hi, Robin. Then you may want to say that `const` guarantees that the name will remain bound to that object. The great-GP is correct in that `const` has nothing to do with immutability besides that. It doesn't necessarily conveys an intent of inner immutability. It just states that whatever is in the variable will stay there until it goes out of scope. Using `const` whenever possible is good advice, off course.

Good point, thank you for the clarification! Somehow I have always thought about showing the intent of keeping the data structure immutable when using const. I have changed it in the article. One more learning for me today :)

Re: JavaScript fundamentals before learning React

#9
post #8

Hey, author here :) I am curious about your experiences using/learning React. Are there any other JavaScript topics which are important when starting out with React? Would be great hearing your opinion!

May want to point out you are the author of the article. :)

Re: JavaScript fundamentals before learning React

#10
post #9
post #8

Hey, author here :) I am curious about your experiences using/learning React. Are there any other JavaScript topics which are important when starting out with React? Would be great hearing your opinion!

May want to point out you are the author of the article. :)

Done :)
Post reply on HN