Coder Social home page Coder Social logo

utilities's Introduction

概览

方法说明:

  • base.getProp([obj, props, dft])

    概述
    getProp() 函数按照一组键值的顺序去查询对象中的键值。

    参数

    obj
    待查询的对象(或数组),如果传入非对象(也不是数组),那么返回 dft 默认值,如果默认值不存在,则返回空字符串。

    props
    一组键名,其中也可夹杂数组索引。

    dft
    查询不到的情况下的默认值。

    例子:

      base.getProp({a: [1, 2, 3]}, ['a']); // 返回 [1, 2 ,3]
      base.getProp({a: [1, 2, 3]}, ['a', 1]); // 返回 2
      base.getProp({a: [1, 2, 3]}, ['a', 1, 'abc']); // 返回空字符串:''
      base.getProp({a: [1, 2, 3]}, ['a', 1, 'abc'], 'default'); // 返回字符串:'default'
  • base.getClassName(obj)
    获取 obj 的类型名。

  • base.isObject(obj)
    判断 obj 是否是一个 Object 类型。

  • base.isFunction(obj)
    判断 obj 是否是一个函数对象。

  • base.isArray(obj)
    判断 obj 是否是一个 Array 类型(不包括类数组)。

  • base.isString(obj)
    判断 obj 是否是 String 类型。

  • base.isNumber(obj)
    判断 obj 是否是 Number 类型。

  • base.extend(obj1, obj2, obj3, ...)
    深度复制合并对象属性,将 obj2 、 obj3 ... 一系列对象属性深复制到 obj1 上,并返回合并后的对象。

  • base.bind(fn, thisArg, arg1, arg2, ...)
    类似于 EcmaScript 5 的 Function.prototype.bind() 方法,给 fn 绑定 thisArg 作为执行上下文(this),并且预传入 arg1 、 arg2 ... 作为函数参数。该函数返回一个函数对象。

  • base.format(str, arg1, arg2, arg3, ...)
    将 arg1 、 arg2 、 arg3 ... 格式化到 str 中,依次替换 str 中的 {0}{1}{2} ... 。

  • base.keys(obj)
    获取 obj 中可枚举的键,返回键数组。

  • base.values(obj)
    获取 obj 中可枚举键对应的键值,返回键值数组。

utilities's People

Stargazers

MR.LI /MR LEE avatar Andy avatar Mingo Duan avatar ueumd avatar 江小白 avatar  avatar

Watchers

James Cloos avatar yibuyisheng avatar  avatar  avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.