Q:

How to parse array/object sent by ajax in NodeJS server

I have a array: passedWord = ['a', 'bbb']
Then I use ajax request to send this array to nodejs server. On server, by Body Parser I receive:
{ name: 'abc', score: '27', 'passedWord[]': [ 'a', 'bbb' ] }

My code:
app.post('/add-score', function (req, res){
  console.log(req.body.passedWord) -->log: undefined
})

how do I read my array on nodejs server

A:

Use bracket notation, which accepts string as the property name
app.post('/add-score', function (req, res){
   console.log(req.body["passedWord[]"]); // now it works
})

What cannot be written as such, due to variable naming rules, in dot notation, can be accessed using bracket notation.

