js console.log打印对像与数组用法详解
作者:bea
本文实例讲述了js console.log打印对像与数组用法。分享给大家供大家参考,具体如下: console.log是什么东西,其实就是一个打印js数组和对像的函数而已,就像是php的print_r,var_dump。console.log这个函数本身没什么好说的,这篇博客告诉大家怎么去用这个函数。在说这个函数之前,我想大家用的最多查看js输出,是alert吧,但是alert,只能弹string或者是int的 一、测试文件test.html <html xmlns
本文实例讲述了js console.log打印对像与数组用法。分享给大家供大家参考,具体如下:
console.log是什么东西,其实就是一个打印js数组和对像的函数而已,就像是php的print_r,var_dump。console.log这个函数本身没什么好说的,这篇博客告诉大家怎么去用这个函数。在说这个函数之前,我想大家用的最多查看js输出,是alert吧,但是alert,只能弹string或者是int的
一、测试文件test.html
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>console.log test</title>
</head>
<script type="text/javascript">
var testobj =
{
'id': 1,
'content': 'test',
'firstname': function() {
document.getElementById('firstname').value = "zhang";
},
'lastname': function() {
document.getElementById('lastname').value = "ying";
}
};
<!-- 打印对像 -->
console.log(testobj);
</script>
<body>
<input type="text" id='firstname' name="firstname" value=''>
<input type="text" id='lastname' name='lastname' value=''>
</body>
</html>
二、chrome 开发工具查看js对像
console chrome
现在chrome开发者工具和firebug,我用的时候,一半对一半。chrome开发者工具,还有一个功能,firebug不具有.
控制台可以运行js,如果这个页面是iframe的话,firebug只能运行在父级上面,而chrome可以选择里面的页面执行,如果下图
chrome iframe console
三、firebug查看js对像
firebug console
更多关于JavaScript数组相关内容感兴趣的读者可查看本站专题:《JavaScript数组操作技巧总结》
希望本文所述对大家JavaScript程序设计有所帮助。
有用 | 无用
console.log是什么东西,其实就是一个打印js数组和对像的函数而已,就像是php的print_r,var_dump。console.log这个函数本身没什么好说的,这篇博客告诉大家怎么去用这个函数。在说这个函数之前,我想大家用的最多查看js输出,是alert吧,但是alert,只能弹string或者是int的
一、测试文件test.html
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>console.log test</title>
</head>
<script type="text/javascript">
var testobj =
{
'id': 1,
'content': 'test',
'firstname': function() {
document.getElementById('firstname').value = "zhang";
},
'lastname': function() {
document.getElementById('lastname').value = "ying";
}
};
<!-- 打印对像 -->
console.log(testobj);
</script>
<body>
<input type="text" id='firstname' name="firstname" value=''>
<input type="text" id='lastname' name='lastname' value=''>
</body>
</html>
二、chrome 开发工具查看js对像
console chrome
现在chrome开发者工具和firebug,我用的时候,一半对一半。chrome开发者工具,还有一个功能,firebug不具有.
控制台可以运行js,如果这个页面是iframe的话,firebug只能运行在父级上面,而chrome可以选择里面的页面执行,如果下图
chrome iframe console
三、firebug查看js对像
firebug console
更多关于JavaScript数组相关内容感兴趣的读者可查看本站专题:《JavaScript数组操作技巧总结》
希望本文所述对大家JavaScript程序设计有所帮助。
有用 | 无用
猜你喜欢
您可能感兴趣的文章:
- 在JavaScript中call()与apply()区别
- 很全面的JavaScript常用功能汇总集合
- JavaScript实现仿淘宝商品购买数量的增减效果
- jQuery头像裁剪工具jcrop用法实例(附演示与demo源码下载)
- JavaScript学习笔记整理之引用类型
- jQuery弹层插件jquery.fancybox.js用法实例
- 基于JS实现新闻列表无缝向上滚动实例代码
- jQuery validate插件实现ajax验证重复的2种方法
- jQuery禁用键盘后退屏蔽F5刷新及禁用右键单击
- 如何利用JS通过身份证号获取当事人的生日、年龄、性别
- jQuery解析json格式数据简单实例
- 基于javascript实现根据身份证号码识别性别和年龄
- 基于jQuery仿淘宝产品图片放大镜特效
- jQuery图片旋转插件jQueryRotate.js用法实例(附demo下载)
- jQuery validate插件submitHandler提交导致死循环解决方法
- jQuery prototype冲突的2种解决方法(附demo示例下载)
- jquery mobile开发常见问题分析
- json格式数据的添加,删除及排序方法
- jquery及js实现动态加载js文件的方法