Implement or Improve Concept Exercise: object-destructuring
See original GitHub issueGetting started
Here you can read about what Concept Exercises are and how they are structured:
If you have not done so yet, it is probably also helpful to do a couple of “Learning Exercises” (this is how they are called on the site) yourself. You can also look at the code of an existing concept exercise like bird-watcher
(concept for-loops
) for reference.
See the documentation above (general documentation), as well as How to implement a Concept Exercise in JavaScript.
Goal
The goal of this exercise is to teach the student how they can destructure an object into multiple bindings (which looks like pattern matching), concept object-destructuring
.
Learning objectives
- Using destructuring to get a property
- Using destructuring to get a nested property
- Using destructurng to get multiple properties (object pattern shorthand)
- Using destructuring to rename properties
- Using destructuring + rest properties to extract a property, and put the rest of the properties in a new name (after.md: React has the pattern
...otherProps
to pass on a few props, but not all). - Using default values in object destructuring
- Using nested destructuring.
Out of scope
- Anything specific with arrays because there is another concept for this
Concepts
object-destructuring
Prerequisites
objects
array-destructuring
- … (do you think something is missing?)
About
- Usage in the parameters directly,
- Usage when extracting data from e.g. a JSON response
- Usage in e.g. React
Help
You can choose to do this solo-style, or collaborate with multiple people on this. The suggested approach is to
- First accept this issue by saying “I’d like to work on this” (no need to wait for a response, just go with it) and optionally request that someone works with you (and wait for a second person to accept your request).
- Use this issue to discuss any questions you have, what should be included in the content and what not and to collect reference material.
- Create a PR and set “exercism/javascript” as reviewers. Additionally you can write in #maintaining-javascript that your PR is ready for review. Once you incorporated any critical feedback that the reviewer might give you and the PR is approved, it will be merged by a maintainer.
Issue Analytics
- State:
- Created 3 years ago
- Comments:9 (9 by maintainers)
Top Results From Across the Web
Object destructuring best practice in Javascript | by Crunch Tech
Object destructuring best practice in Javascript. A summary of the evolution of object property access patterns at Crunch.
Read more >How to Use Object Destructuring in JavaScript - Dmitri Pavlutin
The object destructuring is a JavaScript feature to extract properties from objects and bind them to variables.
Read more >Destructuring Assignment | Advanced JavaScript
Destructuring assignment is syntax in JavaScript that allows you to unpack values from arrays or properties from objects, and save them into variables....
Read more >Destructuring assignment - The Modern JavaScript Tutorial
Destructuring assignment is a special syntax that allows us to “unpack” arrays or objects into a bunch of variables, as sometimes that's more ......
Read more >How to use destructuring in JavaScript to write cleaner, more ...
With destructuring we have to get the values of all the properties present inside the object inside the location array. So we created...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
@SleeplessByte I’d have the exercise be named after the primary concept (which looks to be
object-destructuring
) and have it unlock two concepts:object-destructuring
andrest-properties
.There is a fresh issue for this now (https://github.com/exercism/javascript/issues/1501), I am closing this one.