<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <title>JS-基础语法</title> </head> <body> </body> <script> // 输出语句 // 1. alert() 弹出警告框 alert("Hello World 111!"); // 2. document.write() 输出到页面 document.write("Hello World! 222"); // 3. console.log() 输出到控制台 console.log("Hello World! 333"); </script> </html>
<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <title>JS-基础语法</title> </head> <body> <script> // var声明变量 var a = 10; console.log(a); // JavaScript是弱类型语言,可以随时改变变量的类型 a = "马铃薯"; console.log(a); // 特点1:作用域比较大,全局变量 // 特点2:变量是可以重复定义的 { var b = 20; var b = 200; } console.log(b); </script> </body> </html>
标签:console,log,05,JavaScript,语法,var,World,Hello From: https://www.cnblogs.com/REN-Murphy/p/18026836