标签:
//冒泡排序 function sortBubble(array){ for (var i = 0; i < array.length-1; i++) { var bool = true; for (var j = 0;j <array.length-1; j++) { if (array[j] > array[j+1]){ var temp = array[j]; array[j] = array[j+1]; array[j+1] = temp; bool = false; } }if (bool){ break;//这样才可以 } } return array; //这样才可以返回正确值 } }
var stu = new Student("张三"); function Student(name){ this.name = name; this.sayHi = function(){ console.log (this.name+ "说,大家好!"); } }
属性绑定的方法
对象名.属性 = 属性值;
对象名[变量名] = 对象值;
var json{ "name":"Tom", "sex":"man", }
JSON的值可以是
for(var key, in json){ console.log(key);//打印键名 console.log(json[key]); //打印值 }
标签:
原文地址:http://www.cnblogs.com/mr-yuan/p/5940799.html