Submit Search
簡單介紹JavaScript變數範圍
Download as PPTX, PDF
3 likes
1,392 views
AI-enhanced description
林儀泰 Tommy Lin
文档讨论了变量的访问范围,包括在函数内外的可访问性,强调了ES5与ES6对作用域的不同处理,尤其是在块级作用域声明let的支持上。同时指出,只有嵌套函数能够访问外层变量,外层函数无法访问内层变量。
Presentations & Public Speaking
Read more
1 of 24
Download now
Downloaded 15 times
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
More Related Content
PPTX
5, workflow function activity
ted-xu
PDF
單元測試:Mocha、Chai 和 Sinon
Hsin-Hao Tang
PPTX
检查实现类
Wu Liang
PPT
改善程序设计技术的50个有效做法
crasysatan
PPTX
PHPUnit + Xdebug 单元测试技术
hoopchina
PPT
揭开Javascript的面纱
qiang
PPTX
簡單介紹JavaScript參數傳遞
林儀泰 Tommy Lin
PPTX
簡單介紹JavaScript資料型態
林儀泰 Tommy Lin
5, workflow function activity
ted-xu
單元測試:Mocha、Chai 和 Sinon
Hsin-Hao Tang
检查实现类
Wu Liang
改善程序设计技术的50个有效做法
crasysatan
PHPUnit + Xdebug 单元测试技术
hoopchina
揭开Javascript的面纱
qiang
簡單介紹JavaScript參數傳遞
林儀泰 Tommy Lin
簡單介紹JavaScript資料型態
林儀泰 Tommy Lin
Featured
(20)
PDF
2024 Trend Updates: What Really Works In SEO & Content Marketing
Search Engine Journal
PDF
Storytelling For The Web: Integrate Storytelling in your Design Process
Chiara Aliotta
PDF
Artificial Intelligence, Data and Competition – SCHREPEL – June 2024 OECD dis...
OECD Directorate for Financial and Enterprise Affairs
PDF
How to Leverage AI to Boost Employee Wellness - Lydia Di Francesco - SocialHR...
SocialHRCamp
PDF
2024 State of Marketing Report – by Hubspot
Marius Sescu
PDF
Everything You Need To Know About ChatGPT
Expeed Software
PDF
Product Design Trends in 2024 | Teenage Engineerings
Pixeldarts
PDF
How Race, Age and Gender Shape Attitudes Towards Mental Health
ThinkNow
PDF
AI Trends in Creative Operations 2024 by Artwork Flow.pdf
marketingartwork
PDF
Skeleton Culture Code
Skeleton Technologies
PDF
PEPSICO Presentation to CAGNY Conference Feb 2024
Neil Kimberley
PDF
Content Methodology: A Best Practices Report (Webinar)
contently
PPTX
How to Prepare For a Successful Job Search for 2024
Albert Qian
PDF
Social Media Marketing Trends 2024 // The Global Indie Insights
Kurio // The Social Media Age(ncy)
PDF
Trends In Paid Search: Navigating The Digital Landscape In 2024
Search Engine Journal
PDF
5 Public speaking tips from TED - Visualized summary
SpeakerHub
PDF
ChatGPT and the Future of Work - Clark Boyd
Clark Boyd
PDF
Getting into the tech field. what next
Tessa Mero
PDF
Google's Just Not That Into You: Understanding Core Updates & Search Intent
Lily Ray
PDF
How to have difficult conversations
Rajiv Jayarajah, MAppComm, ACC
2024 Trend Updates: What Really Works In SEO & Content Marketing
Search Engine Journal
Storytelling For The Web: Integrate Storytelling in your Design Process
Chiara Aliotta
Artificial Intelligence, Data and Competition – SCHREPEL – June 2024 OECD dis...
OECD Directorate for Financial and Enterprise Affairs
How to Leverage AI to Boost Employee Wellness - Lydia Di Francesco - SocialHR...
SocialHRCamp
2024 State of Marketing Report – by Hubspot
Marius Sescu
Everything You Need To Know About ChatGPT
Expeed Software
Product Design Trends in 2024 | Teenage Engineerings
Pixeldarts
How Race, Age and Gender Shape Attitudes Towards Mental Health
ThinkNow
AI Trends in Creative Operations 2024 by Artwork Flow.pdf
marketingartwork
Skeleton Culture Code
Skeleton Technologies
PEPSICO Presentation to CAGNY Conference Feb 2024
Neil Kimberley
Content Methodology: A Best Practices Report (Webinar)
contently
How to Prepare For a Successful Job Search for 2024
Albert Qian
Social Media Marketing Trends 2024 // The Global Indie Insights
Kurio // The Social Media Age(ncy)
Trends In Paid Search: Navigating The Digital Landscape In 2024
Search Engine Journal
5 Public speaking tips from TED - Visualized summary
SpeakerHub
ChatGPT and the Future of Work - Clark Boyd
Clark Boyd
Getting into the tech field. what next
Tessa Mero
Google's Just Not That Into You: Understanding Core Updates & Search Intent
Lily Ray
How to have difficult conversations
Rajiv Jayarajah, MAppComm, ACC
Ad
簡單介紹JavaScript變數範圍
1.
Tommy Lin 林儀泰 FB/Email:tooto1985@gmail.com
2.
限制被宣告的變數有效存取範圍 ◦ 函式內可以存取函式外的變數
3.
存取函式外層變數 var a=100; function run()
{ var b=100; console.log(a); } run();
4.
存取函式外層變數 var a=100; function run()
{ var b=100; console.log(a); //100 } run();
5.
限制被宣告的變數有效存取範圍 ◦ 函式內可以存取函式外的變數 ◦
函式外不可存取函式內的變數
6.
存取函式內層變數 var a=100; function run()
{ var b=100; } run(); console.log(b);
7.
存取函式內層變數 var a=100; function run()
{ var b=100; } run(); console.log(b); //undefined
8.
限制被宣告的變數有效存取範圍 ◦ 函式內可以存取函式外的變數 ◦
函式外不可存取函式內的變數 以函式來界定存取範圍(ES5)
9.
函式界定範圍 var a=0; function run()
{ if(true) { var a=1; } console.log(a); } run(); console.log(a);
10.
函式界定範圍 var a=0; function run()
{ if(true) { var a=1; } console.log(a); } run(); console.log(a); //0
11.
函式界定範圍 var a=0; function run()
{ if(true) { var a=1; } console.log(a); //1 } run(); console.log(a); //0
12.
限制被宣告的變數有效存取範圍 ◦ 函式內可以存取函式外的變數 ◦
函式外不可存取函式內的變數 以函式來界定存取範圍(ES5) ◦ ES6支援以區塊界定範圍的宣告let
13.
區塊界定範圍(ES6) function run() { var
a = 0; if(true) { let a=1; console.log(a); } console.log(a); } run();
14.
區塊界定範圍(ES6) function run() { var
a = 0; if(true) { let a=1; console.log(a); //1 } console.log(a); } run();
15.
區塊界定範圍(ES6) function run() { var
a = 0; if(true) { let a=1; console.log(a); //1 } console.log(a); //0 } run();
16.
限制被宣告的變數有效存取範圍 ◦ 函式內可以存取函式外的變數 ◦
函式外不可存取函式內的變數 以函式來界定存取範圍(ES5) ◦ ES6支援以區塊界定範圍的宣告let 必須是套崁函式並非引用函式
17.
套崁函式 var a =
100; function run() { var b = 200; function todo() { console.log(b); } todo(); console.log(a); } run();
18.
套崁函式 var a =
100; function run() { var b = 200; function todo() { console.log(b); //200 } todo(); console.log(a); } run();
19.
套崁函式 var a =
100; function run() { var b = 200; function todo() { console.log(b); //200 } todo(); console.log(a); //100 } run();
20.
引用函式 var a =
100; function todo() { console.log(b); } function run() { var b = 200; todo(); console.log(a); } run();
21.
引用函式 var a =
100; function todo() { console.log(b); } function run() { var b = 200; todo(); console.log(a); //100 } run();
22.
引用函式 var a =
100; function todo() { console.log(b); //undefined } function run() { var b = 200; todo(); console.log(a); //100 } run();
23.
內層可以存取外層 外層不可以存取內層
函式界定存取範圍 區塊界定存取範圍需使用let宣告(ES6) 必須是套崁函式才可存取
24.
https://developer.mozilla.org/en- US/docs/Web/JavaScript/Reference/Statements/var https://developer.mozilla.org/en- US/docs/Web/JavaScript/Reference/Statements/let
Download