在JavaScript中,打印日志通常使用`console.log()`方法。这个方法属于`console`对象,它是一个用于浏览器控制台或Node.js控制台的标准API。
以下是一些使用`console.log()`的基本示例:
```javascript
// 打印一条简单的消息
console.log("Hello, World!");
// 打印变量
console.log("The value of x is: " + x);
// 打印多个值
console.log("The year is", 2023, "and the month is", "April");
// 使用模板字符串打印多个值
console.log(`The year is ${2023