- D3.js 4.x Data Visualization(Third Edition)
- ?ndrew Rininsland Swizec Teller
- 198字
- 2021-07-02 23:20:23
What happened to all the classes?
The second edition of this book contained quite a number of examples using the class feature that is new in ES2015. The revised examples in this edition use factory functions instead, and the class keyword never appears. Why is this, exactly?
ES2015 classes are essentially just syntactic sugaring for factory functions. By this I mean that they ultimately transpile down to factory functions anyway. Although classes can provide a certain level of organization to a complex piece of code, they ultimately hide what is going on underneath it all. Not only that, using OO paradigms, such as classes, is effectively avoiding one of the most powerful and elegant aspects of JavaScript as a language, which is its focus on first-class functions and objects. Your code will be simpler and more elegant using functional paradigms than OO, and you'll find it less difficult to read examples in the D3 community, which almost never use classes.
There are many, much more comprehensive arguments against using classes than I'm able to make here. For one of the best, refer to Eric Elliott's excellent The Two Pillars of JavaScript pieces at:
www.medium.com/javascript-scene/the-two-pillars-of-javascript-ee6f3281e7f3.
- Reporting with Visual Studio and Crystal Reports
- AIRAndroid應(yīng)用開發(fā)實(shí)戰(zhàn)
- 基于免疫進(jìn)化的算法及應(yīng)用研究
- Ray分布式機(jī)器學(xué)習(xí):利用Ray進(jìn)行大模型的數(shù)據(jù)處理、訓(xùn)練、推理和部署
- 正則表達(dá)式經(jīng)典實(shí)例(第2版)
- Getting Started with NativeScript
- Java Web程序設(shè)計(jì)任務(wù)教程
- Web前端應(yīng)用開發(fā)技術(shù)
- Instant Debian:Build a Web Server
- 小程序從0到1:微信全棧工程師一本通
- 深入解析Java編譯器:源碼剖析與實(shí)例詳解
- 算法圖解
- SQL Server 2012 數(shù)據(jù)庫(kù)應(yīng)用教程(第3版)
- Raspberry Pi Robotic Projects
- Selenium Essentials