Notice: This page requires JavaScript to function properly.
Please enable JavaScript in your browser settings or update your browser.
学ぶ Understanding JavaScript Syntax | JavaScript Fundamentals
/
Introduction to JavaScript

bookUnderstanding JavaScript Syntax

メニューを表示するにはスワイプしてください

JavaScript uses parentheses, curly braces, and semicolons as part of its basic syntax.

1
console.log("Hello, user!");
copy

This program prints Hello, user! to the console.

Breaking Down the Syntax

  • console.log(): a method that prints values to the console;
  • Parentheses (): hold the data you want to print;
  • Quotes " " or ' ': tell JavaScript the text is a string;
  • Semicolon ;: marks the end of the command.
Note
Note

In JavaScript, semicolons are optional because the interpreter can often insert them automatically. However, adding semicolons is a good habit, helps avoid rare errors, and keeps your code consistent.

Multiple Commands

Each command ends with a semicolon.

123
console.log("Command 1"); console.log("Command 2"); console.log("Command 3");
copy

Each line is a separate command.

1. What is the purpose of the console.log() method?

2. Why do we use quotes (" or ') around text like "Hello, user!"?

question mark

What is the purpose of the console.log() method?

正しい答えを選んでください

question mark

Why do we use quotes (" or ') around text like "Hello, user!"?

正しい答えを選んでください

すべて明確でしたか?

どのように改善できますか?

フィードバックありがとうございます!

セクション 1.  2

AIに質問する

expand

AIに質問する

ChatGPT

何でも質問するか、提案された質問の1つを試してチャットを始めてください

セクション 1.  2
some-alt