Chinaunix
标题:
JavaScript for in语句
[打印本页]
作者:
feiyang10086
时间:
2011-12-09 16:39
标题:
JavaScript for in语句
JavaScript for in语句
Js代码
1.var tom = {name: 'Tom', gender: 'Male', age: 17};
2.for (att in tom) {
3. alert('tom.' + att + ' = ' + tom[att]);
4.}
5.
6.var protocols = ['HTTP', 'FTP', 'SMTP'];
7.for (index in protocols) {
8. alert('protocols[' + index + '] = ' + protocols[index]);
9.}
var tom = {name: 'Tom', gender: 'Male', age: 17};
for (att in tom) {
alert('tom.' + att + ' = ' + tom[att]);
}
var protocols = ['HTTP', 'FTP', 'SMTP'];
for (index in protocols) {
alert('protocols[' + index + '] = ' + protocols[index]);
}
复制代码
作者:
寂寞冲咖啡
时间:
2011-12-24 20:25
谢谢分享 希望于楼主多多交流
欢迎光临 Chinaunix (http://bbs.chinaunix.net/)
Powered by Discuz! X3.2