What's the formal difference between the types of these two variables in TypeScript?
var randomStringId = () => Math.random().toString(36).substr(2, 9);
function randomStringId2() {
return Math.random().toString(36).substr(2, 9);
}
randomStringId has type () => string. randomStringId2 has type (): string. Are they different? If yes, how? Or is it just my IDE showing differently two types that are fundamentally the same?
randomStringId2can be used BEFORE its declaration, whilerandomStringIdcannot. This is pure JavaScript differences and since TypeScript is a superset of JavaScript, it inherits this difference.