js console.log打印對像與數(shù)組用法詳解
本文實例講述了js console.log打印對像與數(shù)組用法。分享給大家供大家參考,具體如下:
console.log是什么東西,其實就是一個打印js數(shù)組和對像的函數(shù)而已,就像是php的print_r,var_dump。console.log這個函數(shù)本身沒什么好說的,這篇博客告訴大家怎么去用這個函數(shù)。在說這個函數(shù)之前,我想大家用的最多查看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 開發(fā)工具查看js對像
console chrome
現(xiàn)在chrome開發(fā)者工具和firebug,我用的時候,一半對一半。chrome開發(fā)者工具,還有一個功能,firebug不具有.
控制臺可以運行js,如果這個頁面是iframe的話,firebug只能運行在父級上面,而chrome可以選擇里面的頁面執(zhí)行,如果下圖
chrome iframe console
三、firebug查看js對像
firebug console
更多關(guān)于JavaScript數(shù)組相關(guān)內(nèi)容感興趣的讀者可查看本站專題:《JavaScript數(shù)組操作技巧總結(jié)》
希望本文所述對大家JavaScript程序設(shè)計有所幫助。
- js console.log打印對象時屬性缺失的解決方法
- JavaScript 輸出顯示內(nèi)容(document.write、alert、innerHTML、console.log)
- javascript代碼調(diào)試之console.log 用法圖文詳解
- JS中捕獲console.log()輸出的方法
- node.js中的console.log方法使用說明
- js調(diào)試工具console.log()方法查看js代碼的執(zhí)行情況
- JavaScript調(diào)試技巧之console.log()詳解
- javascript的console.log()用法小結(jié)
- 如何使用JS console.log()技巧提高工作效率
相關(guān)文章
JS自定義函數(shù)實現(xiàn)時間戳轉(zhuǎn)換成date的方法示例
這篇文章主要介紹了JS自定義函數(shù)實現(xiàn)時間戳轉(zhuǎn)換成date的方法,結(jié)合具體實例形式分析了javascript時間戳與日期格式的計算與轉(zhuǎn)換相關(guān)操作技巧,需要的朋友可以參考下2017-08-08微信小程序天氣預報功能實現(xiàn)(支持自動定位,附源碼)
對于一個經(jīng)常出門在外的人,關(guān)注天氣是至關(guān)重要的,下面這篇文章主要給大家介紹了關(guān)于微信小程序天氣預報功能實現(xiàn)的相關(guān)資料,文中通過實例代碼介紹的非常詳細,支持自動定位,需要的朋友可以參考下2022-04-04Javascript創(chuàng)建Silverlight Plugin以及自定義nonSilverlight和lowSilverl
我們在使用Visual Studio IDE創(chuàng)建Silverlight工程時,默認情況下都會自動生成一個用于調(diào)試和預覽Silverlight的Web工程,該工程包含了html和aspx頁面,以及Silverlight.js腳本文件。2010-06-06