I'm trying to find a way to make the following possible with NodeJS.
a = 10
b = 20
c = 30
d = 40
......
......
function getObject(a, b, c, d, ....) => {
// this function should return an object.
// return {
a : 10,
b : 20,
c : 30,
d : 40,
.......
.......
}
}
Is there a way to do it in javascript (NodeJS)?
[Edit - Solved]
As suggested by @Offirmo in this thread and @MarkMeyer in the comments, the problem in the question can be solved with ES6 object notation.
let a = 10;
let b = 20;
function getOject(data){
console.log(data)
}
getObject({a,b}) // { a: 10, b: 20 }