angular 基础api介绍
angular.isString
angular.isString判断输入参数是否是字符串,源码如下:1
2
3
4
5
6
7
8
9
10
11
12
13/**
* @ngdoc function
* @name angular.isString
* @module ng
* @kind function 函数
*
* @description
* Determines if a reference is a `String`.
*
* @param {*} value Reference to check. 参数
* @returns {boolean} True if `value` is a `String`. 返回
*/
function isString(value) {return typeof value === 'string';}
angular.isObject
angular.isObject 判断输入参数是否是Object类型1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18/**
* @ngdoc function
* @name angular.isObject
* @module ng
* @kind function
*
* @description
* Determines if a reference is an `Object`. Unlike `typeof` in JavaScript, `null`s are not
* considered to be objects. Note that JavaScript arrays are objects.
在angular中null是不被考虑为object的。 JavaScript的array是object
*
* @param {*} value Reference to check.
* @returns {boolean} True if `value` is an `Object` but not `null`.
*/
function isObject(value) {
// http://jsperf.com/isobject4
return value !== null && typeof value === 'object';
}
angular.isNullObject
判断引用参数是否是带空原型链的对象1
2
3
4
5
6
7
8
9
10/**
* Determine if a value is an object with a null prototype
*
* @returns {boolean} True if `value` is an `Object` with a null prototype
*/
function isBlankObject(value) {
//var getPrototypeOf = Object.getPrototypeOf,
return value !== null && typeof value === 'object' && !getPrototypeOf(value);
}
isArrayLike
1 | /** |