this post was submitted on 15 Aug 2023
13 points (93.3% liked)

No Stupid Questions (Developer Edition)

896 readers
1 users here now

This is a place where you can ask any programming / topic related to the instance questions you want!

For a more general version of this concept check out [email protected]

Icon base by Lorc under CC BY 3.0 with modifications to add a gradient

founded 1 year ago
MODERATORS
 

Do I master Typescript if I master Javascript ? Is Typescript syntax different ? Answers appreciated, thank you !

you are viewing a single comment's thread
view the rest of the comments
[–] [email protected] 13 points 10 months ago (1 children)

Typescript is Javascript with extra rules added to keep you, the developer, honest and explicit. The main way it does this is by enforcing types. This is a whole subject in and of itself, so here’s a lazy hand-wavy example from an internet stranger:

// regular js You, the developer: “hey js compiler, I’m gonna make a new array” JS compiler: “Cool, dude!” You: “Now please push ‘cat’, 5, NaN, and Date.new() onto the array” JS compiler: “No problem my guy (or girl)! You probably know what you’re doing!”

// typescript You, the developer: “hey js compiler, I’m gonna make a new array” Typescript: WHAT. THE. FUCK. Just like that?? An array of what, exactly?! Do you even know?? You’re grounded, mister. Don’t ever try to pull that shit again. The FUCKING nerve.”

Basically you and the compiler are co-parenting a removed js baby and you can pick between deadbeat dad or helicopter Karen mom.

[–] [email protected] 4 points 10 months ago (1 children)

n.b. I tried to call your js baby a word that rhymes with “tree farted” but I got censored. Probably for the best.

[–] [email protected] 5 points 10 months ago (1 children)
[–] [email protected] 3 points 10 months ago (1 children)

let myTrue = true === true ? true : true