json不能用for-of循环,会报错 可以用for-in循环: var json = {'a':'apple','b':'banana','c':'orange','d':'pear'}; for(var name in json){ console.log(name);// a b c d //打印的name值是字符串,所以用json['d']的方式输出 console.log(json[name]);// apple banana orange pear // apple console.…
var Cen = 6;//定义菱形中部为第几行(起始值为0) //for循环输出菱形 document.write("<button onclick='xh()'>点我for循环</button>");//在HTML里输出一个按钮,点击后执行输出菱形的操作 document.write("<p id='xunhuan'></p>");//在HTML里输出一个段落p来容纳菱形 function xh() { var k…