- Mastering JavaScript
- Ved Antani
- 284字
- 2021-07-16 09:31:29
Chapter 2. Functions, Closures, and Modules
In the previous chapter, we deliberately did not discuss certain aspects of JavaScript. These are some of the features of the language that give JavaScript its power and elegance. If you are an intermediate- or advanced-level JavaScript programmer, you may be actively using objects and functions. In many cases, however, developers stumble at these fundamental levels and develop a half-baked or sometimes wrong understanding of the core JavaScript constructs. There is generally a very poor understanding of the concept of closures in JavaScript, due to which many programmers cannot use the functional aspects of JavaScript very well. In JavaScript, there is a strong interconnection between objects, functions, and closures. Understanding the strong relationship between these three concepts can vastly improve our JavaScript programming ability, giving us a strong foundation for any type of application development.
Functions are fundamental to JavaScript. Understanding functions in JavaScript is the single most important weapon in your arsenal. The most important fact about functions is that in JavaScript, functions are first-class objects. They are treated like any other JavaScript object. Just like other JavaScript data types, they can be referenced by variables, declared with literals, and even passed as function parameters.
As with any other object in JavaScript, functions have the following capabilities:
- They can be created via literals
- They can be assigned to variables, array entries, and properties of other objects
- They can be passed as arguments to functions
- They can be returned as values from functions
- They can possess properties that can be dynamically created and assigned
We will talk about each of these unique abilities of a JavaScript function in this chapter and the rest of the book.
- Photoshop智能手機(jī)APP UI設(shè)計(jì)之道
- Apache Hive Essentials
- Access 2010數(shù)據(jù)庫(kù)基礎(chǔ)與應(yīng)用項(xiàng)目式教程(第3版)
- Mastering LibGDX Game Development
- 編譯系統(tǒng)透視:圖解編譯原理
- Spring Boot Cookbook
- 前端HTML+CSS修煉之道(視頻同步+直播)
- JavaCAPS基礎(chǔ)、應(yīng)用與案例
- JavaScript應(yīng)用開發(fā)實(shí)踐指南
- 精通MySQL 8(視頻教學(xué)版)
- Managing Microsoft Hybrid Clouds
- 深度探索Go語(yǔ)言:對(duì)象模型與runtime的原理特性及應(yīng)用
- Android智能手機(jī)APP界面設(shè)計(jì)實(shí)戰(zhàn)教程
- Python數(shù)據(jù)科學(xué)實(shí)踐指南
- JavaScript高級(jí)程序設(shè)計(jì)(第3版)