Correcting teacher:天蓬老师
Correction status:qualified
Teacher's comments:
js是异步的单线程的脚本语言
<button onclick="show(this)">Click me</button>
标签级: script标签
<script>
const btn = document.querySelector('button');
btn.addEventListener('click', show);
function show(ev) {
console.log(ev.target.innerHTML);
ev.target.style.background = 'lightskyblue';
}
</script>
script标签的src属性引入
<script src="js.js"></script>
<script>
// 声明和赋值分开写
// 声明未赋值初始值是underfind
let name;
name = 'jack';
// 声明和赋值写在一行
let name = 'jack';
</script>
<script>
//常量用const声明,常量名一般用大写
const MAN = 'people';
</script>
let user_name;
let userName;
let UserName;
let age = 20;
let name = 'jack';
let request = true;
let name;
null
let age = null;
对象
let man = {
//属性,相当于变量
name = 'jack',
age = 20,
gander = 'man'
//方法,相当于函数
getName: function () {
// this表示当前的上下文,当前对象
return '我的名字:' + this.name;
}
}
数组
let arr = [1,2,3,4]
console.log(arr[2]);
//添加元素
console.log((arr[4] = 99));
console.log(arr);
//修改元素
console.log((arr[0] = 100));
函数
<script>
function hello(a, b, c);
console.log(arguments);
</script>
//添加元素
hello.d = 'd';
console.dir(hello);