ExtJs -- 15 -- Ext. is * various types of judgment methods, you can simply look at the source code to understand, extjs judgment Browser

Source: Internet
Author: User
Tags javascript array

ExtJs -- 15 -- Ext. is * various types of judgment methods, you can simply look at the source code to understand, extjs judgment Browser

        /**         * Returns true if the passed value is empty, false otherwise. The value is deemed to be empty if it is either:         *         * - `null`         * - `undefined`         * - a zero-length array         * - a zero-length string (Unless the `allowEmptyString` parameter is set to `true`)         *         * @param {Object} value The value to test         * @param {Boolean} allowEmptyString (optional) true to allow empty strings (defaults to false)         * @return {Boolean}         * @markdown         */        isEmpty: function(value, allowEmptyString) {            return (value === null) || (value === undefined) || (!allowEmptyString ? value === '' : false) || (Ext.isArray(value) && value.length === 0);        },        /**         * Returns true if the passed value is a JavaScript Array, false otherwise.         *         * @param {Object} target The target to test         * @return {Boolean}         * @method         */        isArray: ('isArray' in Array) ? Array.isArray : function(value) {            return toString.call(value) === '[object Array]';        },        /**         * Returns true if the passed value is a JavaScript Date object, false otherwise.         * @param {Object} object The object to test         * @return {Boolean}         */        isDate: function(value) {            return toString.call(value) === '[object Date]';        },        /**         * Returns true if the passed value is a JavaScript Object, false otherwise.         * @param {Object} value The value to test         * @return {Boolean}         * @method         */        isObject: (toString.call(null) === '[object Object]') ?        function(value) {            // check ownerDocument here as well to exclude DOM nodes            return value !== null && value !== undefined && toString.call(value) === '[object Object]' && value.ownerDocument === undefined;        } :        function(value) {            return toString.call(value) === '[object Object]';        },        /**         * @private         */        isSimpleObject: function(value) {            return value instanceof Object && value.constructor === Object;        },        /**         * Returns true if the passed value is a JavaScript 'primitive', a string, number or boolean.         * @param {Object} value The value to test         * @return {Boolean}         */        isPrimitive: function(value) {            var type = typeof value;            return type === 'string' || type === 'number' || type === 'boolean';        },        /**         * Returns true if the passed value is a JavaScript Function, false otherwise.         * @param {Object} value The value to test         * @return {Boolean}         * @method         */        isFunction:        // Safari 3.x and 4.x returns 'function' for typeof <NodeList>, hence we need to fall back to using        // Object.prototype.toString (slower)        (typeof document !== 'undefined' && typeof document.getElementsByTagName('body') === 'function') ? function(value) {            return toString.call(value) === '[object Function]';        } : function(value) {            return typeof value === 'function';        },        /**         * Returns true if the passed value is a number. Returns false for non-finite numbers.         * @param {Object} value The value to test         * @return {Boolean}         */        isNumber: function(value) {            return typeof value === 'number' && isFinite(value);        },        /**         * Validates that a value is numeric.         * @param {Object} value Examples: 1, '1', '2.34'         * @return {Boolean} True if numeric, false otherwise         */        isNumeric: function(value) {            return !isNaN(parseFloat(value)) && isFinite(value);        },        /**         * Returns true if the passed value is a string.         * @param {Object} value The value to test         * @return {Boolean}         */        isString: function(value) {            return typeof value === 'string';        },        /**         * Returns true if the passed value is a boolean.         *         * @param {Object} value The value to test         * @return {Boolean}         */        isBoolean: function(value) {            return typeof value === 'boolean';        },        /**         * Returns true if the passed value is an HTMLElement         * @param {Object} value The value to test         * @return {Boolean}         */        isElement: function(value) {            return value ? value.nodeType === 1 : false;        },        /**         * Returns true if the passed value is a TextNode         * @param {Object} value The value to test         * @return {Boolean}         */        isTextNode: function(value) {            return value ? value.nodeName === "#text" : false;        },        /**         * Returns true if the passed value is defined.         * @param {Object} value The value to test         * @return {Boolean}         */        isDefined: function(value) {            return typeof value !== 'undefined';        },        /**         * Returns true if the passed value is iterable, false otherwise         * @param {Object} value The value to test         * @return {Boolean}         */        isIterable: function(value) {            var type = typeof value,                checkLength = false;            if (value && type != 'string') {                // Functions have a length property, so we need to filter them out                if (type == 'function') {                    // In Safari, NodeList/HTMLCollection both return "function" when using typeof, so we need                    // to explicitly check them here.                    if (Ext.isSafari) {                        checkLength = value instanceof NodeList || value instanceof HTMLCollection;                    }                } else {                    checkLength = true;                }            }            return checkLength ? value.length !== undefined : false;        }

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.