zoukankan      html  css  js  c++  java
  • phaser源码解析(三) Phaser.Utils类下isPlainObject方法

    /**
        * #这是一个对jQuery.isPlainObject(obj)稍加修改的方法。    一个 普通对象  obj.toString() => "[object Object]"                      
        * This is a slightly modified version of jQuery.isPlainObject. A plain object is an object whose internal class property is [object Object].
        * @method Phaser.Utils.isPlainObject     
        * @param {object} obj - The object to inspect.  ——#等待检查的对象 
        * @return {boolean} - true if the object is plain, otherwise false. ——#ture代表是一个普通对象, 否则返回false
        */
        isPlainObject: function (obj) {
    
            // Not plain objects: 不是 普通对象 包括:
            //#任何对象和值内置property属性的值不是[object Object]
            // - Any object or value whose internal [[Class]] property is not "[object Object]"  
            // - DOM nodes       ——#Dom对象
            // - window         ——#window对象
            if (typeof(obj) !== "object" || obj.nodeType || obj === obj.window)
            {
                return false;
            }
    
            // Support: Firefox <20
            // The try/catch suppresses exceptions thrown when attempting to access
            // the "constructor" property of certain host objects, ie. |window.location|
            // #判断obj是否具有isPrototypeOf属性,isPrototypeOf是挂在Object.prototype上的。通过字面量或自定义类(构造器)创建的对象都会继承该属性方法.
         //解释引子:http://www.cnblogs.com/phpmix/articles/1733599.html
            try {
                if (obj.constructor && !hasOwn.call(obj.constructor.prototype, "isPrototypeOf"))
                {
                    return false;
                }
            } catch (e) {
                return false;
            }
    
            //#如果通过了以上的验证
            // If the function hasn't returned already, we're confident that
            // #我们就可以认为参数obj是一个普通对象,通过{}和new创建的对象
            // |obj| is a plain object, created by {} or constructed with new Object
            return true;
        }
  • 相关阅读:
    <Yarn> <Capacity Scheduler> <Source Code>
    [Paper] LCS: An Efficient Data Eviction Strategy for Spark
    [Paper] Selection and replacement algorithm for memory performance improvement in Spark
    Zookeeper与Paxos
    Paxos工程实践
    Join Algorithm
    《c# 从入门经典》 (第6版)
    Unity Standard Assets 简介之 2D
    Unity Standard Assets 简介之 Utility
    《Invert》开发日志03:一些想法
  • 原文地址:https://www.cnblogs.com/DhyDream/p/3593457.html
Copyright © 2011-2022 走看看