我有一个对象数组,我必须按index
属性上的重复值将其拆分。对于像下一个这样的对象示例数组:
[
{index: 0, value: 3},
{index: 0, value: 3},
{index: 0, value: 3},
{index: 1, value: 3},
{index: 1, value: 3},
{index: 2, value: 3},
{index: 2, value: 3}
]
Run Code Online (Sandbox Code Playgroud)
预期结果应该是:
{
0: [
{index: 0, value: 3},
{index: 0, value: 3},
{index: 0, value: 3}
],
1: [
{index: 1, value: 3},
{index: 1, value: 3}
],
2: [
{index: 2, value: 3},
{index: 2, value: 3}
]
}
Run Code Online (Sandbox Code Playgroud) var express = require('express');
var app = express();
app.get('/', function(req, res){
res.send('hello world');
});
app.listen(3000);
Run Code Online (Sandbox Code Playgroud)
我收到以下错误.
> D:\nodejs\mynode\index.js:2
> var app=express();
^
ReferenceError: express is not defined
at Object.<anonymous> (D:\nodejs\mynode\index.js:2:9)
at Module._compile (module.js:456:26)
at Object.Module._extensions..js (module.js:474:10)
at Module.load (module.js:356:32)
at Function.Module._load (module.js:312:12)
at Function.Module.runMain (module.js:497:10)
at startup (node.js:119:16)
at node.js:902:3
Run Code Online (Sandbox Code Playgroud)