zoukankan      html  css  js  c++  java
  • 总结js基础方法


    //判断对象上是否有个这个属性 hasPro
    return obj != null && hasOwnProperty.call(obj, key);


    //判断是不是布尔值 isBoolean
    return obj === true || obj === false || toString.call(obj) === '[object Boolean]';


    //判断是不是对象 isObject
    var type = typeof obj;
    return type === 'function' || type === 'object' && !!obj;


    //判断是不是为空 isNull
    return obj === null;

    //判断如果obj是undefined返回true。 isUndefined
    return obj === void 0;


    //获取某区间的随机数
    _.random = function(min, max) {
    if (max == null) {
    max = min;
    min = 0;
    }
    return min + Math.floor(Math.random() * (max - min + 1));
    };


    //获取时间
    _.now = Date.now || function() {
    return new Date().getTime();
    };

    //判断是不是function
    _.isFunction = function(obj) {
    return typeof obj == 'function' || false;
    };

  • 相关阅读:
    The AndroidManifest.xml File
    handlebars简单用法
    高性能跨语言模板引擎Crox
    C++17 新特性
    C++ 14新特性
    [lua]笔记
    [lua]笔记
    delphi关键字
    delphi 基础
    TCP/UDP
  • 原文地址:https://www.cnblogs.com/rainheader/p/5254111.html
Copyright © 2011-2022 走看看