- 0
- 0
- 约2.19千字
- 约 3页
- 2026-02-06 发布于北京
- 举报
复习
见思维导图
学门编程语言的基本步骤
(1)了解背景知识:、现状、特点、应用场景
(2)开发环境:编写helloworld
(3)变量和常量
(4)数据类型
(5)运算符
(6)逻辑结构
(7)通用小程序
(8)函数和对象
(9)第库、框架
(10)实用的项目
1.函数
没有名称的函数function(){}
创建函数——函数
functionfn(){}
(1)创建函数——函数表达式
var函数名称=function(形参列表){
函数体
return值;
}
调用:函数名称(实参列表)
对比函数和函数表达式的区别
函数存在函数提升,可以在任意位置创建,也可以在任意位置调用。
函数表达式不存在函数提升,存在变量提升,必须先创建再调用。
练习:使用函数创建函数getSum,传递1个参数,返回1~任意数字之间所有的和。
(2)函数自调用
(function(){
函数体;//是一个局部作用域,无法被外界
})();
(3)函数以参数传递——回调函数
functionadd(a){
//形参a就相当于是函数名称
a();//调用传递的函数
}
add(function(){...})
Reviewsee
mindmap
Basicstepstolearnaprogramminglanguage(1)Understand
backgroundknowledge:history,currentstatus,characteristics,
applicationscenarios(2)Setupthedevelopmentenvironment:write
helloworld(3)variabandconstants(4)data
types(5)operators(6)logicalstructures(7)generalsmall
programs(8)functionsandobjects(9)third-partylibraries,
frameworks(10)practicalprojects
1.Anonymousfunctions
Functionswithoutanamefunction(){}
Creatingfunctions—functiondeclarations
functionfn(){}
(1)Createfunction——Function
expression
varfunctionName==function(parameters){
函数体
returnvalue;
}
Call:functionName(arguments)
Comparethedifferencesweenfunction
declarationsandfunctionexpressions
Fntiondeclarationsarehoisted,allowingthemtobecreatedandcalledfromanyposition.
uc
Functionexpressionsdonothavefunctionhoisting,buttheydohavevariablehoisting;theymustbecreatedbeforetheycanbecalled.
Exercise:UseananonymousfunctiontocreateafunctiongetSum,whichtakes1parameterandreturnsthesumofallnumbers
ween1~anytwonumbers.
(2)Self-invoking
anonymousfunction
(function(){
functionbody;//Itisalocalscope,notaccessiblefromtheoutside
})();
(3)Passinganonymousfunctionsasparameters—
您可能关注的文档
最近下载
- 专题01 概括文章主要内容( 讲义)(原卷+答案解释)2024-2025学年小升初语文讲练测 统编版.docx VIP
- 红酒葡萄酒礼仪知识培训实用PPT讲授课件.pptx
- 海尔Haier洗碗机 EW139166BK 说明书.pdf
- 05G514-2 12m实腹式钢吊车梁(中级工作制 A4 A5 Q235钢)建筑工程 图集 .docx VIP
- 长沙蓝天救援队入队申请表2019.doc VIP
- 分层审核点检表.docx VIP
- 力矩紧固施工技术方案-01.docx
- 2024年广东东莞东华高级中学自主招生数学试卷(含答案详解).docx VIP
- 变电运维工作总结.docx VIP
- 南京市本劳动合同书(2008版).pdf VIP
原创力文档

文档评论(0)