9 / 11 · Book 12 · Your First Program← prev⊞ allnext →Get the book →
1.9Quiz: Chapter 1
- What command runs a TypeScript file named
test_login.tswithout compiling it first? - What is the difference between
print(),console.log(), and how does TypeScript's output differ from JavaScript's? - How do you start the Python REPL? The Node.js REPL?
- What does a
SyntaxErrortell you? - Name one advantage TypeScript has over JavaScript for catching bugs.
Answers:
npx tsx test_login.ts(on Node.js 24+,node test_login.tsalso works via native type-stripping)print()is Python's output function.console.log()is used by both JavaScript and TypeScript. TypeScript's runtime output is identical to JavaScript -- the types are erased at runtime.- Python: type
pythonorpython3. Node: typenode. - That the code structure is invalid -- something is misspelled, unmatched, or missing (like a closing quote or parenthesis).
- TypeScript catches type errors at compile time, before the code runs. JavaScript only catches them at runtime.