Constants in Go Vs. Constants in Javascript

Written by wagslane | Published 2020/09/02
Tech Story Tags: cryptography | compile | constant | global | go | golang | javascript | const

TLDR 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.via the TL;DR App

no story

Written by wagslane | Founder of Boot.dev. Whining about coding sins since 2011. Committing coding sins for the same.
Published by HackerNoon on 2020/09/02