类与原型 [英] Class vs Prototype

查看:17
本文介绍了类与原型的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

是什么让 ES6 类的语法比传统的原型方法更好?

What makes ES6 class syntax better than traditional prototype approach?

由于我不关心跨浏览器的东西,我应该用类替换所有当前对象吗?

Should I replace all my current objects with classes since I don't care about the cross browser stuff?

推荐答案

ES6 类是基于原型的 OO 模式的一个简单的糖.拥有一个方便的声明形式使类模式更易于使用,并鼓励互操作性.类支持基于原型的继承、超级调用、实例和静态方法和构造函数.

ES6 classes are a simple sugar over the prototype-based OO pattern. Having a single convenient declarative form makes class patterns easier to use, and encourages interoperability. Classes support prototype-based inheritance, super calls, instance and static methods and constructors.

这篇关于类与原型的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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