JavaScript JavaScript: Object destructuring dynamically via computed keys javascript object destructuring rename,javascript object destructuring default value,javascript

I'm trying to write a curried function dissoc, that takes in a prop and an object and removes the key and its value from the object.

Here is the code that works:

const dissoc = prop => obj => {
  const result = {};
  for (let p in obj) {
    result[p] = obj[p];
  }
  delete result[prop];
  return result;
};

Now, I thought this could be written more concise by using computed properties, destructuring and the rest operator:

const dissoc = prop => ({ [prop], ...obj}) => obj

But this code throws with:

Uncaught SyntaxError: Unexpected token ,

So I tried:

const dissoc = prop => ({ prop, ...obj}) => obj

which computes, but just returns the object without the prop.

Is there a way to dynamically destructure and / or simplify this code?

Answer:1

I would like to know how to disable unselected checkboxes using jQuery. The goal is to disable the unselected checkboxes if the number of selected checkboxes is greater than or equal to 3. $('....

I would like to know how to disable unselected checkboxes using jQuery. The goal is to disable the unselected checkboxes if the number of selected checkboxes is greater than or equal to 3. $('....

  1. disable unchecked checkbox jquery
  2. disable unchecked checkbox javascript
  3. unchecked disabled checkbox

I have developed this neat little piece of code which given an element and a properly formatted table, creates a dropdown menu on the element which allows the user to toggle view of columns. I cannot ...

I have developed this neat little piece of code which given an element and a properly formatted table, creates a dropdown menu on the element which allows the user to toggle view of columns. I cannot ...

  1. javascript html table to csv
  2. javascript html table library
  3. javascript html table to json
  4. javascript html table to excel
  5. javascript html table to array
  6. javascript html table sort
  7. javascript html table filter
  8. javascript html table pagination
  9. javascript html table add row
  10. javascript html table search
  11. javascript html table example
  12. javascript html table generator
  13. javascript html table insert row
  14. javascript html table column width
  15. javascript html table to xlsx
  16. javascript html table to pdf
  17. javascript html table to excel xlsx
  18. javascript html table delete all rows
  19. javascript html table
  20. javascript html table export to excel

To understand async/await, I am trying to display a console message once settimeout runs and expires. How do I fix my code below? I have 5 settimeout function and each should display respective ...

To understand async/await, I am trying to display a console message once settimeout runs and expires. How do I fix my code below? I have 5 settimeout function and each should display respective ...

  1. using async await
  2. using async await c#
  3. using async await javascript
  4. using async await in node js
  5. using async await in react
  6. using async await mongoose
  7. using async await in node
  8. using async await axios
  9. using async await and promises
  10. using async await fetch
  11. use async await in angular 6
  12. using async without await
  13. using async await with callback functions
  14. async with await
  15. async with await python
  16. async with await c#
  17. use effect async await
  18. why use async await in web api

Hi i'm using Jquery Upload plugin. I've got this problem: when i upload the first file this work fine,a single request is sent. But if i select a second file and i upload it,two request are sent and ...

Hi i'm using Jquery Upload plugin. I've got this problem: when i upload the first file this work fine,a single request is sent. But if i select a second file and i upload it,two request are sent and ...

  1. when do we choose another president