TypeScript for Beginners / Chapter 1 — Starting with TypeScript (lessons 1–6) / Lesson 1
What TypeScript is
Time needed: about 9 min (estimate)
Reading settings
These settings are remembered on this device only.
You can try the opening of this lesson without an account.
In JavaScript you cannot see the mistake until you run it
Here is a function in JavaScript that adds tax.
On the second call "1200" is a string, so the + becomes string concatenation rather than addition.
The problem is not that the result differs — it is that JavaScript does not treat this as a mistake.
In a real application price comes from a form field or an API response, so this mistake only surfaces once a user does something.
Tab indents. To leave the editor, press Esc, then Tab.
Create a free account to keep reading
With an account you can read the rest of this lesson, take the quiz, and read every free lesson in this course. Lessons you answer correctly are recorded as complete.
Report a problem with this lesson
Log in to send a report.