TypeScript Tutorial

TypeScript Output

console.log sends text to the console. That is how every first program talks back.

console.log writes to the console

console.log is the standard way to print. You pass it a value, or several values. After the program runs, you see those characters in the console — on StudyGrid, that is the output pane under the editor. This is TypeScript’s equivalent of C++ cout.

Example

console.log("Hello from console.log");

Open examples with Try it in TypeScript. That is /typescript/try: a tsc compile-and-run editor.

Pass several values

One call can take many arguments. StudyGrid joins them with a space, the same way Node does. Mixing strings and numbers is normal. You do not chain << the way C++ does.

Example

console.log("Score:", 12, "points");
console.log(3, "plus", 4, "is", 3 + 4);

The order is left to right. First the label, then the number, then more text. You can also build one string with+ and pass that single value.

Each call starts a new line

console.log ends with a newline. The next call prints on the next line. To print two lines from one string, put \n inside the quotes.

Example

console.log("first line");
console.log("second line");
console.log("third line\nfourth line");

Arguments in one call stay on the same line. Two separate console.log calls become two lines. Forget that and you split a sentence that should have stayed together.

Numbers, booleans, and strings

console.log prints integers, floating-point values, booleans, and quoted text. Aboolean prints as the words true and false, not as 1 and0 the way C++ cout often does.

Example

const count: number = 7;
const price: number = 2.5;
const ready: boolean = true;
console.log(count);
console.log(price);
console.log(ready);
console.log("done");

Spaces between arguments are automatic

Separate arguments get a space between them. If you concatenate with + instead, you must put the spaces in yourself. "Hi" + "there" is Hithere.

CodeWhat you see
console.log(2, 5);2 5
console.log(2 + "" + 5);25
console.log("n=" + 3);n=3

Nothing to include

C++ needs <iostream> before cout. TypeScript does not. console is there from the start. Change a printed value and compile again.

Next: comments, so you can leave notes next to the lines that print.

FAQ: TypeScript Output

Common questions about this page.

What is the StudyGrid TypeScript tutorial?

The StudyGrid TypeScript tutorial follows the same chapter rhythm as C++: syntax, types, input, loops, functions, classes, generics, maps, and lambdas. Each chapter has copy-and-run examples.

Should I run typescript console.log examples locally for better learning?

Yes. Use the browser editor on StudyGrid for a quick check, then Download the example and run it on your computer. Local runs show real errors and the real toolchain, which is one of the fastest ways to learn typescript console.log in this TypeScript TypeScript lesson (TypeScript Output).

Is the TypeScript editor the same as Try Python or Try C++?

No. Try TypeScript type-checks with tsc at /typescript/try and shows stdout plus compiler messages. Try Python stays at /try. Try C++ stays at /cpp/try. TypeScript lessons never open those editors.

Do I need to install a compiler to learn TypeScript?

No. Open a chapter, click Try it in TypeScript, and compile in the browser. You can also download a .ts file and compile locally with tsc.

Where should I start the TypeScript tutorial?

Start at TypeScript Intro, then Get Started and Syntax. After the first program, continue to output, variables, and if-else. After classes, open TypeScript Examples, then generics, Map, and arrow functions. Use Next at the bottom of each chapter.

Is the TypeScript tutorial free?

Yes. The TypeScript workshop on StudyGrid (studygrid.in) is free: dashboard, chapters, and the compile-and-run editor.