Hacker News new | past | comments | ask | show | jobs | submit login

const in C++ is very different than const in JavaScript though. I guess you are well aware of that but I feel like being pedantic.

This is allowed in JavaScript:

    const foo = {bar: 1};
    foo.bar = 2;



It's not really any different if you keep in mind that foo is a reference here, and so that's what const applies to. The equivalent in C++ would be a const pointer to a non-const object.


const foo = Object.freeze({bar: 1});




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: