zoukankan      html  css  js  c++  java
  • vue.js源码学习分享(三)

    /**
     * Mix properties into target object.//把多个属性插入目标的对象
     */
    function extend (to, _from) {
      for (var key in _from) {
        to[key] = _from[key];
      }
      return to
    }
    
    /**
     * Quick object check - this is primarily used to tell
     * Objects from primitive values when we know the value
     * is a JSON-compliant type.//检查是不是对象
     */
    function isObject (obj) {
      return obj !== null && typeof obj === 'object'
    }
    
    /**
     * Strict object type check. Only returns true
     * for plain JavaScript objects.//严格的对象检查
     */
    var toString = Object.prototype.toString;
    var OBJECT_STRING = '[object Object]';
    function isPlainObject (obj) {
      return toString.call(obj) === OBJECT_STRING
    }
    
    /**
     * Merge an Array of Objects into a single Object.//相当于复制一个数组
     */
    function toObject (arr) {
      var res = {};
      for (var i = 0; i < arr.length; i++) {
        if (arr[i]) {
          extend(res, arr[i]);
        }
      }
      return res
    }
    
    /**
     * Perform no operation.无操作
     */
    function noop () {}
    
    /**
     * Always return false.//总是返回false
     */
    var no = function () { return false; };
    
    /**
     * Return same value//返回相同的值
     */
    var identity = function (_) { return _; };
  • 相关阅读:
    C# macro function via #define __FILE__ __LINE__ ___FUNCTION__ __DATE__ __TIME__
    3
    2月23号
    3月26
    impala故障
    2月3号日更
    HDFS某个节点的磁盘满了
    3月2
    mq集群
    3月3
  • 原文地址:https://www.cnblogs.com/liuhao-web/p/6669693.html
Copyright © 2011-2022 走看看