search

Home  >  Q&A  >  body text

angular.js - 使用AngularJS 封装函数和使用Javascript 原生函数有什么区别?

比如大小写转换,JSON转换,forEach之类的。

大家讲道理大家讲道理2902 days ago337

reply all(2)I'll reply

  • 伊谢尔伦

    伊谢尔伦2017-04-10 15:12:19

    angular 会在 scope 上的对象增加一些额外的属性,通常是 $$ 为前缀的东西, angular 封装的 toJSON fromJSON 方法会把这些在序列化的时候去掉,不至于造成数据的污染。

    至于 forEach,文档上如是说:

    Unlike ES262's Array.prototype.forEach, Providing 'undefined' or 'null' values for obj will not throw a TypeError, but rather just return the value provided.

    嗯,其实看文档就好

    reply
    0
  • PHP中文网

    PHP中文网2017-04-10 15:12:19

    图方便的话你就直接用angular的这些内置实用方法,如果想自己折腾一下,那就自己封装原生函数,具体区别你可以直接点开源码阅读。

    reply
    0
  • Cancelreply