You aren’t though. In most languages that use the latter declaration you would prefix the declaration with final or const or the like to specify it won’t be updated.
But if it were rust, this meme would not make sense, since you would just type let a and type inference would do its thing. Which is much more ergonomic.
You’re encoding more information in the typescript one. You’re saying it’s a string that will get updated.
C# has const string a = “Hello, World”;
var in js is legacy, and default should be let, but changing that would break everything
Yeah, it’s explicitly distinct from
const a: String
which says it won’t change, andvar a: String
, which means this is legacy code that needs fixing.If there’s only two options you only need one keyword
True, but var and let are not same in js, so there is three.
if(true) {
var a = "dumdum"
}
console.log(a)
Is valid and functioning javascript. With let it is not.
You aren’t though. In most languages that use the latter declaration you would prefix the declaration with final or const or the like to specify it won’t be updated.
deleted by creator
That looks like rust ngl
It’s also valid rust syntax.
But if it were rust, this meme would not make sense, since you would just type
let a
and type inference would do its thing. Which is much more ergonomic.let a = String::from(“Hello, world!”).into()
I’ll see myself out.
I was thinking the same thing. who would write typescript if they could just do Rust?