在 underscore.js 中有一个方法 _.invert console.log(_.invert({ a: 1, b: 2 })) <script src="//jashkenas.github.io/underscore/underscore-min.js"></script>