前端常用的一些方法
来源:互联网 发布:android 相机源码 编辑:程序博客网 时间:2024/04/29 02:04
1、js判读是否为数组
var arr1 = [];
Object.prototype.toString.call(arr1) === '[object Array]'
2、Javascript For/In 循环: 循环遍历对象的属性
var person={fname:"John",lname:"Doe",age:25};
for (x in person)
{
txt=txt + person[x];
}
结果:JohnDoe25
3、jQuery jQuery.each() 遍历对象属性
var arr = ["one", "two", "three", "four", "five"];
var obj = { one: 1, two: 2, three: 3, four: 4, five: 5 };
4、遍历数组
var text = "Array ";
jQuery.each(arr, function(i, val) {
text = text + " #Index:" + i + ":" + val;
});
console.log(text);
//Array #Index:0:one #Index:1:two #Index:2:three #Index:3:four #Index:4:five
5、遍历对象
text = "Object ";
jQuery.each(obj, function(i, val) {
text = text + "Key:" + i + ", Value:" + val;
});
console.log(text);
//Object Key:one, Value:1Key:two, Value:2Key:three, Value:3Key:four, Value:4Key:five, Value:5
- 前端常用的一些方法
- 前端:常用的方法
- 前端常用的优化方法
- 一些常用的方法
- 一些常用的方法
- 一些常用的方法
- 一些常用的前端开发规范
- 一些常用的前端基础操作
- 一些常用的前端基础操作
- 一些常用的前端基础操作
- 前端交互封装的一些javaScript方法
- 前端常用的获取参数的方法
- [前端] 关于数组的常用方法统计
- ASP常用的一些方法
- MFC常用的一些方法
- 反射常用的一些方法
- 常用的一些js方法
- HttpRequest的一些常用方法
- android AsyncTask介绍
- 直接写入html输出流
- iOS进阶面试题
- UVa Live 7147 贪心(2014 上海区域赛)
- UI一揽子计划 3 (自定义视图、UIViewControllor、屏幕旋转判断和重布局)
- 前端常用的一些方法
- netty3升级到4后由于线程模型的变化引起的问题
- UI一揽子计划 4 (Touch 、摇一摇、响应者链)
- tomcat请求修改为nio处理的配置说明
- PAT-A | 1004 | Counting Leaves
- UI一揽子计划 5 (Target: Action: 、Protocol Delegate、 UIImageView 、手势识别器)
- linux系统启动tomcat报错
- UI一揽子计划 6 (UIControl、UISegmentedControl、UIImageView插入数组图片、UISlider)
- UI一揽子计划 7 ( UIScrollView、 UIPageControl、综合所学简单相册)