Understanding JavaScript Syntax
メニューを表示するにはスワイプしてください
JavaScript uses parentheses, curly braces, and semicolons as part of its basic syntax.
1console.log("Hello, user!");
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
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.
123console.log("Command 1"); console.log("Command 2"); console.log("Command 3");
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!"?
すべて明確でしたか?
フィードバックありがとうございます!
セクション 1. 章 2
AIに質問する
AIに質問する
何でも質問するか、提案された質問の1つを試してチャットを始めてください
セクション 1. 章 2