Avatar ·

What is TypeScript and why use it instead of JavaScript?

Hello colleagues! I'm a beginner frontend developer, writing in pure JavaScript for about six months. Lately I keep hearing about TypeScript, but I can't understand why it's needed if JavaScript works perfectly fine. I have a simple project — an online store. I wrote a function to calculate the cart total: ```javascript function calculateTotal(price, quantity) { return price * quantity; } let total = calculateTotal('100', 2); // Error: string instead of number console.log(total); // Outputs "1002" — concatenation, not multiplication! ``` Because I accidentally passed a string instead of a number, the program gave an incorrect result. JavaScript didn't warn me about the error, and I spent an hour searching for it. Such bugs happen constantly: either a variable turns out to be undefined, or...