iT邦幫忙

2022 iThome 鐵人賽

DAY 7
0
自我挑戰組

I don't know JS yet系列 第 7

[ Day 7 ] I don't know JS yet - treat each JS file as a program

  • 分享至 

  • xImage
  •  

回想昨天的學習,JS 的推演其中重要的因素就是效能,從 2013 年的 Unreal 3 engine 問世,其利用 ASM.js 來達到在 browser JS engine 有更高的效能;爾後 WASM 誕生了,其主要縮短了 JS 被執行的速度,有別於以往在 JS engine 做解析、編譯, WASM 會將 JS 預先轉換成 binary packed,再傳進 JS engine,讓 engine 可以直接被執行,以此來縮短 JS 總體的執行時間;

昨天的文章是 Get Started 第一章節的最後一篇文,最後引述作者對 JS 的 defination:

JS is an implementation of the ECMAScript standard (version ES2019 as of this writing), which is guided by the TC39 committee and hosted by ECMA. It runs in browsers and other JS environments such as Node.js.

JS is a multi-paradigm language, meaning the syntax and capabilities allow a developer to mix and match (and bend and reshape!) concepts from various major paradigms, such as procedural, object-oriented (OO/classes), and functional (FP).

JS is a compiled language, meaning the tools (including the JS engine) process and verify a program (reporting any errors!) before it executes.

With our language now defined, let's start getting to know its ins and outs.

開始今天份的學習

回想第五篇鐵人賽發文, JS 是直譯式語言,其特性是在 error handling 時,error 之前的 codes 會被執行;
用稍微廣一點的視角來看,如果一個專案由五個 JS 檔案組成,第五個 JS 檔存在一些錯誤,專案在執行時可能因此而壞掉;
因此作者認為「 將每一份 JS 檔案視作一個專案 」用這樣的心態去撰寫 JS,每一份 JS 檔案會與其餘的 JS 檔案合作,讓整個專案順利進行,倘若有其中一份 JS 檔出現錯誤,就等同於整份專案壞掉了。

今天份的學習到這邊


上一篇
[ Day 6 ] I don't know JS yet - WASM
下一篇
[ Day 8 ] I don't know JS yet - values
系列文
I don't know JS yet30
圖片
  直播研討會
圖片
{{ item.channelVendor }} {{ item.webinarstarted }} |
{{ formatDate(item.duration) }}
直播中

尚未有邦友留言

立即登入留言