- The Node Craftsman Book
- Manuel Kiessling
- 205字
- 2021-07-02 23:36:52
A classless society
JavaScript does not have classes. But as in other languages, we would like to tell the interpreter that it should build our myCar object following a certain pattern or schema or blueprint – it would be quite tedious to create every car object from scratch, manually giving it the attributes and methods it needs every time we build it.
If we were to create 30 car objects based on the Car class in Java, this object-class relationship provides us with 30 cars that are able to drive and honk without us having to write 30 drive and honk methods.
How is this achieved in JavaScript? Instead of an object-class relationship, there is an object-object relationship.
Where in Java our myCar, asked to honk, says go look at this class over there, which is my blueprint, to find the code you need, JavaScript says go look at that other object over there, which is my prototype, it has the code you are looking for.
Building objects via an object-object relationship is called prototype-based programming, versus class-based programming used in more traditional languages like Java.
Both are perfectly valid implementations of the object-oriented programming paradigm – it's just two different approaches.
- Cybersecurity:Attack and Defense Strategies
- 阿里云數(shù)字新基建系列:云原生操作系統(tǒng)Kubernetes
- 嵌入式Linux系統(tǒng)開發(fā):基于Yocto Project
- VMware Horizon View 6 Desktop Virtualization Cookbook
- 嵌入式應(yīng)用程序設(shè)計(jì)綜合教程(微課版)
- Linux運(yùn)維最佳實(shí)踐
- 嵌入式系統(tǒng)原理及開發(fā)
- Android物聯(lián)網(wǎng)開發(fā)細(xì)致入門與最佳實(shí)踐
- 一學(xué)就會(huì):Windows Vista應(yīng)用完全自學(xué)手冊(cè)
- 分布式高可用架構(gòu)之道
- Heroku Cloud Application Development
- iOS 10 開發(fā)指南
- Web Penetration Testing with Kali Linux(Third Edition)
- 嵌入式微系統(tǒng)
- Docker容器技術(shù)與應(yīng)用