Class vs Prototype [英] Class vs Prototype

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

问题描述

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



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

解决方案

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


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 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.

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

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