本文實(shí)例講述了Javascript中For In語句用法。分享給大家供大家參考。具體如下:
<html xmlns="http://www.w3.org/1999/xhtml"><head><meta http-equiv="Content-Type" content="text/html; charset=utf-8" /><title>For In 語句</title><script type="text/javascript">function Student(name, age) {  this.name = name;  this.age = age;}var stu = new Student("內(nèi)馬爾", 20);//遍歷對象for (var s in stu) {  alert(s + ":" + stu[s]);}//遍歷數(shù)組var myArr = [1, 3, 5, 7, 9];for (var i in myArr) {  alert(i + ":" + myArr[i]);}</script></head><body></body></html>希望本文所述對大家的javascript程序設(shè)計(jì)有所幫助。
新聞熱點(diǎn)
疑難解答