+function() { var i = 0 var values = ['xiaoming', 'xiaohong'] var name = values[i] i++ console.log(name, i) }(); // better +function() { var i = 0 var values = ['xiaoming', 'xiaohong'] var name = values[i++] console.log(name, i) }();