Web源码笔记Day06:编程语言学习基本步骤与实践.pdfVIP

  • 0
  • 0
  • 约2.19千字
  • 约 3页
  • 2026-02-06 发布于北京
  • 举报

Web源码笔记Day06:编程语言学习基本步骤与实践.pdf

复习

见思维导图

学门编程语言的基本步骤

(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—

文档评论(0)

1亿VIP精品文档

相关文档