Adding keys to Javascript object conditionally

if foo in query object is exist than i will create a object with that key.

var obj = {
  ...query.foo && { foo: query.foo },
};

Write a Reply or Comment

Your email address will not be published.