使用Prototype扩展本机对象不好吗? [英] Is using Prototype to extend native objects bad?

查看:158
本文介绍了使用Prototype扩展本机对象不好吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在某处读到了使用 prototype 来扩展本机对象( String Number 数组等)是一个坏主意。这是真的?为什么或为什么不呢?

I read somewhere that using prototype to extend native objects (String, Number, Array, etc.) was a bad idea. Is this true? Why or why not?

推荐答案

我认为这不好。如果您看一下Ruby on Rails,很多本地对象都会使用自定义功能进行扩展,这是一个非常好的框架。

I don't think it's bad. If you have a look at Ruby on Rails, very many native objects are extended with custom functionality and it's a very good framework.

如果你更改本机对象上的现有方法。这可能会导致不可预见的后果。

What would be bad is if you change existing methods on native objects. this could cause unforseen consequences.

这篇关于使用Prototype扩展本机对象不好吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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