<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>阿芮的博客 &#187; 对象</title>
	<atom:link href="http://chinarui.yo2.cn/tag/%e5%af%b9%e8%b1%a1/feed" rel="self" type="application/rss+xml" />
	<link>http://chinarui.yo2.cn</link>
	<description>关注计算机软件、互联网应用，记录生活点滴，分享情感片段</description>
	<lastBuildDate>Sun, 17 Jul 2011 09:43:38 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0</generator>
		<item>
		<title>遍历JavaScript对象的属性和值</title>
		<link>http://chinarui.yo2.cn/study/iterate_an_js_object-s_properties_and_values.html</link>
		<comments>http://chinarui.yo2.cn/study/iterate_an_js_object-s_properties_and_values.html#comments</comments>
		<pubDate>Sat, 08 Nov 2008 02:35:10 +0000</pubDate>
		<dc:creator></dc:creator>
				<category><![CDATA[技术|学习]]></category>
		<category><![CDATA[JavaScript]]></category>
		<category><![CDATA[值]]></category>
		<category><![CDATA[对象]]></category>
		<category><![CDATA[属性]]></category>
		<category><![CDATA[遍历]]></category>

		<guid isPermaLink="false">http://chinarui.yo2.cn/articles/%e9%81%8d%e5%8e%86%4a%61%76%61%53%63%72%69%70%74%e5%af%b9%e8%b1%a1%e7%9a%84%e5%b1%9e%e6%80%a7%e5%92%8c%e5%80%bc.html</guid>
		<description><![CDATA[JavaScript调试起来很不方便，有时候需要知道某个对象有哪些属性和值，利用下面的代码就可以了： function getAttribute(obj) { // 用来保存所有的属性名称和值 var props = ""; // 开始遍历 for(var p in obj){ // 方法 if(typeof(obj[p])=="function" { obj[p](); }else{ if(typeof(obj[p])=="object" { //递归 getAttribute(obj[p]); }else{ // p 为属性名称，obj[p]为对应属性的值 props+= p + "=" + obj[p] + "t"; } } } // 最后显示所有的属性 document.write(props + " " ; }]]></description>
			<content:encoded><![CDATA[<p>JavaScript调试起来很不方便，有时候需要知道某个对象有哪些属性和值，利用下面的代码就可以了：</p>
<p><pre class="php">
function getAttribute(obj) {
// 用来保存所有的属性名称和值
var props = "";
// 开始遍历
for(var p in obj){
// 方法
if(typeof(obj[p])=="function" <img src='http://chinarui.yo2.cn/wp-includes/images/smilies/icon_wink.gif' alt=';)' class='wp-smiley'> {
obj[p]();
}else{
if(typeof(obj[p])=="object" <img src='http://chinarui.yo2.cn/wp-includes/images/smilies/icon_wink.gif' alt=';)' class='wp-smiley'> {
//递归
getAttribute(obj[p]);
}else{
// p 为属性名称，obj[p]为对应属性的值
props+= p + "=" + obj[p] + "t";
}
}
}
// 最后显示所有的属性
document.write(props + "
" <img src='http://chinarui.yo2.cn/wp-includes/images/smilies/icon_wink.gif' alt=';)' class='wp-smiley'> ;
}
</pre></p>
]]></content:encoded>
			<wfw:commentRss>http://chinarui.yo2.cn/study/iterate_an_js_object-s_properties_and_values.html/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

