读书人

JavaScript for in话语

发布时间: 2012-11-09 10:18:48 作者: rapoo

JavaScript for in语句

?

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]);}var comment = 'It is beautiful.';var str = '';for (s in comment) {str = str + ', ' + s;}str = str.slice(2);alert(str);

读书人网 >JavaScript

热点推荐