paint-brush
Constants in Go Vs. Constants in Javascriptby@wagslane
133 reads

Constants in Go Vs. Constants in Javascript

by Lane Wagner3mSeptember 2nd, 2020
Read on Terminal Reader
Read this story w/o Javascript
tldt arrow

Too Long; Didn't Read

Constants can be confusing and easy to misuse in Go if you are coming from an untyped language. Constants in Go must be able to be assigned at compile time. The value of a const can't be the result of a runtime calculation. They can be mutated (but not reassigned), if they are of a type that has inner workings that change, like an array or object like an object. They must be assigned before the program runs, that is, when the program compiles using go build. This makes them slightly faster. They can run faster because the compiler can make specific optimizations.

People Mentioned

Mention Thumbnail
featured image - Constants in Go Vs. Constants in Javascript
Lane Wagner HackerNoon profile picture
Lane Wagner

Lane Wagner

@wagslane

Founder of Boot.dev. Whining about coding sins since 2011. Committing coding sins for the same.

About @wagslane
LEARN MORE ABOUT @WAGSLANE'S
EXPERTISE AND PLACE ON THE INTERNET.
L O A D I N G
. . . comments & more!

About Author

Lane Wagner HackerNoon profile picture
Lane Wagner@wagslane
Founder of Boot.dev. Whining about coding sins since 2011. Committing coding sins for the same.

TOPICS

THIS ARTICLE WAS FEATURED IN...

Permanent on Arweave
Read on Terminal Reader
Read this story in a terminal
 Terminal
Read this story w/o Javascript
Read this story w/o Javascript
 Lite
Also published here
Learnrepo
Coffee-web