Mutability of arrays

Hi everyone,

DISCLAIMER: I’m a student, who wants to get into web application hacking and mobile hacking. In order not to go the path everyone else is and hopefully have an edge over other hackers, I made the (not sure if it was wise or a waste of time ) decision to learn the side of what’s being hacked from ground up which is why I’m starting with the FS dev course. So that i can see it from a broader perspective when looking for vulnerabilities
SO PLEASE forgive my question should it be very obvious, I could not find the answer.

I was wondering in ES6, ‘let’ was introduced, which allows variables to be reassigned.
My question is, (as is saw it in a piece of pseudocode), is there any way in which a const array is declared
then somehow that const is modified into a let? OR as in the code snippet I saw (I cant find the site at the moment) be reassigned in value?

Thank you and again apologies for me noob question. :slight_smile:

const means that you can’t reassign a variable, so if you have

const arr = [0, 1, 2] you could never go arr = [1, 2, 3] because that’s reassigning it.

You can however changes the properties of the array (or object if it was an object) i.e. it is perfectly valid to go arr[0] = 1 because that isn’t reassigning the array it is just changing the properties of the object.

P.S. fully understanding web dev first and how developers think is 100% the best way to go


Thanks a lot! Got it the variable always remains immutable, just in case its an object then the properties may change. That was probable what was in the snipped still cant locate it it looked strange and i just took away that a declared var was modified but it must have been the obj properties, Thanks for taking the time!

1 Like

This topic was automatically closed 41 days after the last reply. New replies are no longer allowed.