Hacker News
new
|
past
|
comments
|
ask
|
show
|
jobs
|
submit
login
speedgoose
on Aug 12, 2021
|
parent
|
context
|
favorite
| on:
Fishdraw: Procedurally Generated Fish Drawings
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;
int_19h
on Aug 12, 2021
|
next
[–]
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.
zeven7
on Aug 13, 2021
|
prev
[–]
const foo = Object.freeze({bar: 1});
Guidelines
|
FAQ
|
Lists
|
API
|
Security
|
Legal
|
Apply to YC
|
Contact
Search:
This is allowed in JavaScript: