Movatterモバイル変換


[0]ホーム

URL:


Skip to content
DEV Community
Log in Create account

DEV Community

Sujith V S
Sujith V S

Posted on

     

Destructuring in JavaScript | ES6

Destructuring is used to extract the array elements or object properties and store them in variables.
See the example below,

Object destructuring

//Array destructuringconst number = [1, 2, 3];const [num1, , num3] = numberconsole.log(num1, num3)Output:1 3
Enter fullscreen modeExit fullscreen mode

Array destructuring

//Object destructuringconst myFriends = {    friend1:'Nivedh',    friend2:'Vibin',    friend3:'Joel'}const {friend2, friend1} = myFriendsconsole.log(friend1, friend2)Output:Nivedh Vibin
Enter fullscreen modeExit fullscreen mode

Top comments(0)

Subscribe
pic
Create template

Templates let you quickly answer FAQs or store snippets for re-use.

Dismiss

Are you sure you want to hide this comment? It will become hidden in your post, but will still be visible via the comment'spermalink.

For further actions, you may consider blocking this person and/orreporting abuse

React | Django | ..
  • Joined

More fromSujith V S

DEV Community

We're a place where coders share, stay up-to-date and grow their careers.

Log in Create account

[8]ページ先頭

©2009-2025 Movatter.jp