A program 程序 is a list of instructions for the computer. In JavaScript, each instruction is a statement 语句, and the computer runs the statements from top to bottom.
console.log(...) prints a value in the console 控制台, the text area under the code:
console.log("Hello, world!");
console.log(7 * 6); // 42
- Text goes inside quotes:
"Hello"or'Hello'. Numbers do not. - End each statement with a semicolon
;. JavaScript can often guess where one is missing, but writing it is clearer. - JavaScript is case-sensitive 区分大小写:
console.logworks,Console.Logdoes not.
console.log can print several values at once. It puts one space between them:
console.log("Total:", 3 + 4); // Total: 7
console.log(1, 2, 3); // 1 2 3