for循环对象

来源:互联网 发布:贪心算法的设计思想 编辑:程序博客网 时间:2024/06/06 02:21
<!DOCTYPE html><html><head><meta charset="utf-8" /><title>测试</title><link rel="stylesheet" type="text/css" href="css/t.css"/></head><body ><script>//定义json数组var obj={wan:"wang","yu":"wang2",sex:"男"};function read(){alert(obj.wan);alert(obj.yu)alert(obj.sex);obj.sex="女";}//for循环对象function forEach(){for(var c in obj){alert("得出当前:"+obj[c]);}}read();alert(obj.sex);forEach();</script></body></html>

0 0
原创粉丝点击