Warning: count(): Parameter must be an array or an object that implements Countable in /www/wwwroot/www.xcondor.cn/usr/plugins/AMP/Action.php on line 381

Warning: getimagesize(): Filename cannot be empty in /www/wwwroot/www.xcondor.cn/usr/plugins/AMP/Action.php on line 469
数组对象排序按照JSONarray排序

沙漠里的小蜜蜂

数组对象排序按照JSONarray排序

<script>
		var arr = [{id:1,username:'a1'},{id:2,username:'a2'},{id:3,username:'a3'},{id:4,username:'a4'},{id:5,username:'a5'}];
		var newArr = [3,1,2,5,4];
		let curArr = [];
		for(let i = 0;i<arr.length;i++){
			for(let j = 0;j<newArr.length;j++){
				if(arr[i].id === newArr[j]){
					curArr.unshift(newArr[j])
					console.log('s'+curArr)
				}
			}
		}

		console.log(curArr);

	</script>

 

当前页面是本站的「Google AMP」版。查看和发表评论请点击:完整版 »

因本文不是用Markdown格式的编辑器书写的,转换的页面可能不符合AMP标准。