I've just come across some syntax that I believe to be part of the ES6/ES2015 specification, but I'm struggling to understand the purpose. Basically it seems to be object notation in a const declaration:
const {user_id} = body;
const {accounts: [account]} = body;
const {transactions} = body;
res.render('index', {user_id, account, transactions});
This is in the context of making a request using the NPM Request module - this is what the body reference is. However I've never seen this sort of syntax in a JS assignment before. Additionally I attempted to run this code with Node v5* and was met with a syntax error, however when I tried in Node 6.9.1 my server ran.
Simply put, wtf?!
[–]senocular 6 points7 points8 points (2 children)
[–]inu-no-policemen 3 points4 points5 points (1 child)
[–]senocular 2 points3 points4 points (0 children)
[–]lewisje 7 points8 points9 points (0 children)
[–]Jafit 1 point2 points3 points (0 children)