Skip to content
Navigation Menu
Sign in
Products
Platform
GitHub
Repository hosting, code review, and collaboration
Copilot
AI coding agent for tasks, projects and automated work
Build & Ship
Actions
CI/CD and automation
Code Quality
Quality analysis, fixes, and enforcement
Codespaces
Cloud development environments
Secure
Code Security
Vulnerability detection and remediation
Secret Protection
Secret scanning and leak prevention
All Features
Developers
Learn
Documentation
Training
Certifications
Build
Build with Copilot
Customize Copilot
Integrations
Explore
Trending repos
GitHub Sponsors
Developer articles
Changelog
Changelog
Your source for the latest features, improvements, and fixes across GitHub products, all in one place.
Businesses
By Stage
Enterprises
Team
Startups
Nonprofits
By Industry
Healthcare
Financial services
Manufacturing
Government
See all industries
Evaluate GitHub
Why GitHub
Customer Stories
Business insights
Trust Center
Add-ons
GitHub Advanced Security
Enterprise-grade code security
Copilot for business
Enterprise-grade AI features
Premium Support
Enterprise-grade 24/7 support
Resources
Learn & Connect
Documentation
Resource center
Blog
Events & webinars
Community Forum
Customer Stories
Integrations
Support
Customer support
Training
GitHub Status
Company
About
Partners
Changelog
GitHub Universe
GitHub Universe
The event for developers, by developers — talks, workshops, and what’s next for GitHub.
Pricing
Search
/
Sign in
Sign up
Appearance settings
You signed in with another tab or window.
Reload
to refresh your session.
You signed out in another tab or window.
Reload
to refresh your session.
You switched accounts on another tab or window.
Reload
to refresh your session.
Dismiss alert
{{ message }}
mayao517357028
JavaScript-notes
Repository navigation
Code
Pull requests
Actions
Projects
Security and quality
Insights
More
items
Files
Expand file tree
master
Breadcrumbs
JavaScript-notes
/
第三章 函数.txt
Copy path
Blame
More file actions
Blame
More file actions
Latest commit
History
History
History
59 lines (33 loc) · 1.46 KB
master
Breadcrumbs
JavaScript-notes
/
第三章 函数.txt
Copy path
Top
File metadata and controls
Code
Blame
59 lines (33 loc) · 1.46 KB
Raw
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
1、函数:一种代码的分组形式。(要使用函数,则必须去调用它)
2、如果设置了参数,而少写了某个参数,js会把它默认为undefined,如过多写了会它忽略
3、注意:arguments实际上不是一个数组,而是一个类似数组的对象。
4、isNaN() 函数:判断输入值是否是一个非数字,数值输出false,非 数字输出true
parseInt():将输入值(字符串)转化为整数类型输出
parseFloat():y与上面基本相同
eval()里面的内容将被当作js代码来执行
例子: var a=12;
function(){
alert(a);
var a=1;
alert(a);
}
//undefined
//1
注意:函数域优先于全局域,所以局部变量会覆盖所有与它同名的全局变量,尽管在alert()第一次调用时,a还未正式定义(undefined),但该变量本身已经存在于本地空间了
5、函数也是一种数据类型,只不过这种类型有两个特征:a:包含的是代码 b:是可执行的(可调用的)
笔记:
js运行过程:
1)预编译过程:将所有的变量(全局函数(形参也会创建出来))创建出来,赋值为undefined,但是其他所有的赋值语句等等都不会执行。
2)再调用执行过程
递归函数:自己会调用自己,实现无限循环
一个函数如果有返回值那么它的值就是这个值,如果没有那么它就是undefined 有return的是有返回值的函数,没有return那么它就是undefined
构造函数:
类的属性(成员变量)
类的方法(成员方法)
回调函数:将函数当参数传入的函数就是回调函数;
变量存在栈中,对象存在堆中,栈的效率比堆大的多。(因为对象的占的内存比较大)
js执行过程:
a)预编译过程(第一过程):
1)对所有带var 的变量进行创建,并赋值为undefined,但是不会执行任何赋值语句。
2)对所有带function关键字的函数进行创建,但不会执行
b)执行过程(第二过程):逐条执行各行语句
You can’t perform that action at this time.