我有一个JavaScript对象数组:
var objs = [
{ first_nom: 'Lazslo', last_nom: 'Jamf' },
{ first_nom: 'Pig', last_nom: 'Bodine' },
{ first_nom: 'Pirate', last_nom: 'Prentice' }
];
Run Code Online (Sandbox Code Playgroud)
如何根据last_nomJavaScript中的值对它们进行排序?
我知道sort(a,b),但这似乎只适用于字符串和数字.我是否需要为toString()对象添加方法?
我有两个数组:问题和UserProfile
userProfiles:[]数组包含{ id, name }对象questions:[]数组包含{ id, text, createdBy }对象createdBy问题中的整数始终是其中一个id值userProfiles.
有没有一种方法可以"加入"数组,就像我使用数据库时加入两个SQL表一样.
作为最终结果我需要的是包含的数组
{ id, text, name }
Run Code Online (Sandbox Code Playgroud)