# Code coverage report for thinkjs/lib/Common/extend.js

## Statements: 100% (11 / 11) Branches: 75% (3 / 4) Functions: 100% (3 / 3) Lines: 100% (11 / 11) Ignored: none

All files » thinkjs/lib/Common/ » extend.js

    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30

    2

    243
    243
    1688
    1688

    243

    2

    7
    7
    23

    7

     //该文件内容为原生对象的扩展

    /**
     * 获取对象的值
     * @param  {[type]} obj [description]
     * @return {[type]}     [description]
     */
    Object.values = function(obj){
      'use strict';
      var values = [];
      for(var key in obj){
        Eif (obj.hasOwnProperty(key)) {
          values.push(obj[key])
        }
      }
      return values;
    };
    /**
     * 数组求和
     * @return {[type]} [description]
     */
    Array.prototype.sum = function(){
      'use strict';
      var count = 0;
      this.forEach(function(item){
        count += parseFloat(item) || 0;
      });
      return count;
    };