HexLibraryHexLibrary
</> HexCodeSign inSign up
PythonJavaScriptTypeScriptCC++JavaPHPGoRustRubyBashSQLLuaPerlCOBOLPascalDelphiFortranDartSwiftC#JuliaGroovyRElixirHaskellKotlinScalaClassic ASPClipperMS-DOS
LESSONS
Introduction to JavaScriptVariables (let / const)Data TypesOperatorsStringsArraysObjectsConditions (if / else)Loops (for / while)FunctionsArrow Functions (=>)Array Methods (map / filter / reduce)
REFERENCE
📖 Overview
🖥️ Output & Console
console.log()Template literal ( `` )typeof
📦 Variables
🔢 Numbers & Math
✍️ String
📋 Array
🗂️ Object
🔁 Condition & Loop
🧩 Function
🔄 Type & Conversion
JavaScript›REFERENCE›Output & Console
🖥️

Output & Console

Printing values, concatenating strings, and checking types.

CommandDescription
console.log()Writes value(s) to the console.
Template literal ( `` )Embeds a variable/expression inside text.
typeofReturns the type of a value.

console.log()

Try it yourself →

Writes value(s) to the console.

Syntax

console.log(value1, value2, ...)

Description

Writes the values inside the parentheses to the output; if you provide multiple separated by commas, it puts spaces between them. It's the main tool for debugging and showing results.

Parameters

valueOne or more values to print.

Returns

Returns nothing (undefined); writes to the console.

Example

console.log("Hello", "World");
console.log(1 + 2);

Expected output

Hello World
3

When to use?

Do not show results, monitor variable values, debugging.

Common mistakes

  • ⚠️ In the browser, console.log output appears in the developer console (F12), not on the page.

Template literal ( `` )

Try it yourself →

Embeds a variable/expression inside text.

Syntax

`text ${expression} text`

Description

Written with backticks (`); you put variables or expressions inside ${ }. It is much more readable than concatenating with +. It also allows multiline text.

Returns

Concatenated text (string).

Example

const name = "Alex";
const score = 95;
console.log(`${name} scored ${score}`);

Expected output

Alex scored 95

When to use?

Combining variables with text, HTML/message templates.

Common mistakes

  • ⚠️ Instead of normal quotes ' ", backticks ` should be used.
  • ⚠️ Writing {} instead of ${} does not insert the value.

typeof

Try it yourself →

Returns the type of a value.

Syntax

typeof value

Description

Returns the type of the value as a string: "number", "string", "boolean", "object", "undefined", "function".

Returns

Type name (string).

Example

console.log(typeof 5);
console.log(typeof "a");
console.log(typeof true);

Expected output

number
string
boolean

When to use?

Checking the type of incoming data, debugging.

Common mistakes

  • ⚠️ typeof null → returns 'object' (a historical quirk of the language).
HexLibraryHexLibrary

Learn programming more clearly. Every command is explained line by line with colors, reinforced with runnable exercises, test your code instantly — all in one place, free.

Learn

  • Home
  • Languages & Lessons
  • HexCode

Company

  • About
  • Contact

Legal

  • Privacy Policy
  • Terms of Use

Other Projects

  • HexToolz
  • Free Service Manuals
© 2026 HexLibrary · The clearest way to learn code