总结js基础方法
2016-03-08 15:03
585 查看
//判断对象上是否有个这个属性 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;
};
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;
};
相关文章推荐
- JavaScript 语言基础知识点总结
- js比较日期字符串
- js验证输入字段是否含有字母数字function checkChar(ic) { if (ic >= 48 && ic <= 57) { return 1; } if ((i
- Javascript模块化编程
- js中关于邮箱号、手机号。。等的正则验证模板
- JavaScript笔试题
- Js 日期格式化 yyyy-MM-dd
- commen.js
- JavaScript正则表达式小记
- json 操作
- 利用Jmeter 实现Json格式接口测试
- 利用Jmeter 实现Json格式接口测试
- javascript中的作用域
- 10028---jsp中常用操作字符串的el表达式
- SeaJs 初学
- JVM性能调优监控工具jps、jstack、jmap、jhat、jstat使用详解
- javascript之window对象
- 返回json数据null判断问题
- you don't know js读书笔记
- js代码执行顺序与作用域