|
|
|
|
|
by wruza
1691 days ago
|
|
Usually it doesn’t make a difference neither in speed, nor in size, because of “interning” of literals. Unless you jsonify it, of course. It could show up, if you’d later compare .type with some “CRE”+”ATE” values made funny way, but not for literals, e.g.: // x.js
export const foo = "foo"
// y.js
if (x.foo === "foo") {
// ^ as cheap as int
}
const foo2 = "FOO".toLowerCase()
if (x.foo === foo2) {
// ^ questionable
// depends on jit/optimization
}
https://stackoverflow.com/questions/5276915/do-common-javasc...https://en.wikipedia.org/wiki/String_interning |
|