用Javascript可以进行OOP吗? [英] IS OOP possible in Javascript?

查看:51
本文介绍了用Javascript可以进行OOP吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我最近发现Javascript函数可以具有类,因此我想知道OOP是否也可以通过javascript实现.是吗?如果是,请您指出一些教程或网站,我可以从那里开始?

I recently found out that Javascript function can have classes, so I was wondering if OOP is also possible through javascript. Is It? If yes, Could you please point out some tutorials or site, where I can start with?

推荐答案

绝对可以进行OOP.尽管Javascript不像大多数OO语言那样具有类",但它具有的却称为原型".基本上,对象是根据其他对象而不是类来定义的.(对象也可以在某种程度上模拟类,对于那些无法将原型继承心定下来的人.)

OOP is definitely possible. While Javascript doesn't have "classes" like most OO languages do, what it does have is called "prototypes". Basically, objects are defined in terms of other objects rather than classes. (Objects can also emulate classes to some degree, for those who can't wrap their minds around prototypal inheritance.)

可以认为JS的OO能力超过了大多数语言,因为考虑到对象比具有类的语言起着更重要的作用.

One could argue JS's OO capabilities exceed those of most languages, considering objects play an even more essential role than in languages with classes.

这篇关于用Javascript可以进行OOP吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆