function fun1(obj){ var names={}; /*for in 可以用于数组或者对象*/ for(var name in obj){ names[name] = obj[name].toLowerCase() } console.log(names); }; var obj1 = {username: 'NAME', password: 'WOSHIDHS123'}; fun1(obj1);