Blogger Information
Blog 19
fans 1
comment 0
visits 12260
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
js作业一常识类
▽空城旧梦
Original
812 people have browsed it

script引入方式

1.内部脚本

<script></script>
2.外部脚本
<script src="path"></script>
3.行内脚本
<button type="button" onclick="myFunction()">试一试</button>

<script>
function myFunction() {
document.getElementById(“demo”).innerHTML = “段落被更改。”;
}
</script>

变量与常量

1.声明变量 let(作用域) var(全局)
2.常量 const

函数

1.函数格式
命名函数

  1. function sum(a,b)
  2. {
  3. return a+b;
  4. }
  5. 匿名函数
  6. let sum=function(a,b)
  7. {
  8. return a+b;
  9. }
  10. 2.归并参数和箭头函数
  11. 注意事项箭头函数不能用this
  12. let nums=(...arr)=>console.log(arr)
  13. 3.高阶函数
  14. 语法:function demo(functio(){})
  15. {
  16. return function(){}
  17. }
  18. 4.立即执行函数
  19. (函数声明)(函数调用)
  20. 主要解决变量作用域问题
Correcting teacher:天蓬老师天蓬老师

Correction status:qualified

Teacher's comments:
Statement of this Website
The copyright of this blog article belongs to the blogger. Please specify the address when reprinting! If there is any infringement or violation of the law, please contact admin@php.cn Report processing!
All comments Speak rationally on civilized internet, please comply with News Comment Service Agreement
0 comments
Author's latest blog post