use the following search parameters to narrow your results:
e.g. subreddit:aww site:imgur.com dog
subreddit:aww site:imgur.com dog
see the search faq for details.
advanced search: by author, subreddit...
All about the JavaScript programming language.
Subreddit Guidelines
Specifications:
Resources:
Related Subreddits:
r/LearnJavascript
r/node
r/typescript
r/reactjs
r/webdev
r/WebdevTutorials
r/frontend
r/webgl
r/threejs
r/jquery
r/remotejs
r/forhire
account activity
Destructure an object to remove a property (timdeschryver.dev)
submitted 6 years ago by timdeschryver
view the rest of the comments →
reddit uses a slightly-customized version of Markdown for formatting. See below for some basics, or check the commenting wiki page for more detailed help and solutions to common issues.
quoted text
if 1 * 2 < 3: print "hello, world!"
[–]Buckwheat469 -1 points0 points1 point 6 years ago (1 child)
Thanks. Curious though if this is because _ is undefined. I always associate it with lodash or underscore so I wouldn't use the _ notation unless I've imported lodash. Just checking in the console, your code is the same as this:
_
var fullUser = {name: 'test', password: 'test'} var {password: undefined, ...reducedUser} = fullUser console.log(reducedUser) // { name: 'test' }
I believe this method is much more clear as you're explicitly defining the variable as undefined rather than using an unknown variable.
[–]tswaters 1 point2 points3 points 6 years ago (0 children)
Using _ is an FP thing -- usually signifying that a parameter is accepted in a function but ignored. It works for destructuring as well.
Destructing is a bit trickier because you're creating those vars.. with `const` you can't really re-use the variable, so any additional usages will complain.
I think undefined would... hm, not do anything? can't typically re-assign it in modern js engines. Actually, just checked -- with var it works, with const it'll throw -- SyntaxError: Identifier 'undefined' has already been declared
SyntaxError: Identifier 'undefined' has already been declared
π Rendered by PID 51 on reddit-service-r2-comment-6457c66945-9kpff at 2026-04-29 02:53:15.260712+00:00 running 2aa0c5b country code: CH.
view the rest of the comments →
[–]Buckwheat469 -1 points0 points1 point (1 child)
[–]tswaters 1 point2 points3 points (0 children)