Code Monkey home page Code Monkey logo

Comments (10)

jeremylt avatar jeremylt commented on July 20, 2024 1

I feel like it should be mentioned somewhere, but probably the first lesson where its needed

from freecodecamp.

lasjorg avatar lasjorg commented on July 20, 2024 1

I think it is part of teaching strings.

Here is how MDN words it:

In JavaScript, primitive values are immutable — once a primitive value is created, it cannot be changed, although the variable that holds it may be reassigned another value.

But it would certainly be worth circling back to it when it becomes relevant to make sure the practical implication of it is shown.

from freecodecamp.

ganesh-159th avatar ganesh-159th commented on July 20, 2024 1

Good point! Reassigning variables is key. Perhaps mentioning immutability later reinforces the distinction between variable and data type
@NilsGke

from freecodecamp.

jeremylt avatar jeremylt commented on July 20, 2024

We should avoid parenthetical information like that whenever we can, in my opinion. It makes the sentence much harder to parse.

from freecodecamp.

ojeytonwilliams avatar ojeytonwilliams commented on July 20, 2024

Is it even worth mentioning here? The lesson doesn't show any consequences of immutability, so it might simply be better to remove the sentence.

from freecodecamp.

ganesh-159th avatar ganesh-159th commented on July 20, 2024

The description accurately mentions that strings in JavaScript are immutable, meaning their contents cannot be changed once created. However, it's important to clarify that while strings themselves are immutable, the variables holding them can be reassigned to new values. Therefore, no changes are necessary in this instance. @NilsGke

from freecodecamp.

NilsGke avatar NilsGke commented on July 20, 2024

I agree, the description is correct, though for someone encountering variables, strings and immutability for the first time, they might get confused, thinking they cannot change the variable as it is a string, which is immutable.

Two lessons later you learn how to reassign variables. Maybe not mentioning immutability at this early stage is the better choice.

from freecodecamp.

naomi-lgbt avatar naomi-lgbt commented on July 20, 2024

I would be fine moving it to somewhere closer to where something like array mutation is taught.

from freecodecamp.

lasjorg avatar lasjorg commented on July 20, 2024

I think we should at least update the text to say the variable can be reassigned another value.

This early on in the learning process, the difference between a "value" and a "variable containing a value", is likely not that well understood.

In some other challenge step, we then show what it actually means that a primitive value is immutable. After they know how to index into a value, then we can show an attempt to update an immutable value directly and explain why it doesn't work.

from freecodecamp.

naomi-lgbt avatar naomi-lgbt commented on July 20, 2024

Let's start there, then. A PR which resolves this issue will update the text:

Note that strings are immutable, which means once they are created, they cannot be changed.

To the text:

Note that strings are immutable, which means once they are created, they cannot be changed. The variable can still be reassigned another value.

from freecodecamp.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.