2015年4月6日 星期一

Javascript loop

JavaScript supports different kinds of loops:
  • for - loops through a block of code a number of times
  • for/in - loops through the properties of an object


the for/in used in self defined property;

var person = {fname:"John", lname:"Doe", age:25};
var text = "";
var x;
for (x in person) {
    text += person[x];
}

沒有留言:

張貼留言