批改状态:合格
老师批语:你一直学得很认真, 继续
<!DOCTYPE html><html lang="en"><head><meta charset="UTF-8" /><meta name="viewport" content="width=device-width, initial-scale=1.0" /><title>Document</title><!-- 当script使用src属性时,忽略内部文件脚本,使用外部文件脚本 --><!-- async属性: 可以实现外部的js文件与当前的html文件的解析同步进行 --><!-- defer属性, 将会延迟加载外部的js文件,直到当前的html解析完成 --><script>var name = "angle";//每条语句后用分号结束,可以不写var sex = "female";var age = "32";var Name = "hugn";var Sex = "male";var Age = "32";//js中变量区分大小写function show() {console.log("show函数");console.log("姓名:" + name); //js中的变量可以先使用在定义,所以name显示undefinedvar name = "Eric"; //如果在函数中重新定义了该变量,跟外部的name是两个变量//变量前只要有var关键字,就是重新定义一个变量,即使名字相同console.log("姓名:" + name); //js函数中可以直接使用函数外部定义的变量console.log("性别:" + sex);console.log("年龄:" + age);}function Show() {console.log("Show函数");console.log("姓名:" + Name);console.log("性别:" + Sex);console.log("年龄:" + Age);}//js中函数名称也区分大小写show();if (age > 30) {//js中变量没有块作用域name = "Eric"; //当变量前没有var关键字,说明给变量重新赋值,console.log(name + "已过而立之年");}Show();if (Age > 30) {console.log(Name + "已过而立之年");}</script></head><body><h2>hello world!</h2></body></html>

Copyright 2014-2025 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号