SlideShare a Scribd company logo
Destructuring | ES6
JAGADEESH PATTA ( PJ )
Agenda
 Introduction
 Destructuring by Declaration
 Object Destructuring
 Array Destructuring
 Destructuring array as function response
 Default Values and Ignore Variables
 Destructuring by rest params
 Destructuring by computed property name
Agenda
 Destructuring is an expression.
 Destructuring makes it possible to unpack values from arrays, objects and
variables into distinct variables.
Destructuring by Declaration
Syntax
[ var_1, var_2 ] = [ val_1, val_2 ]
Example
[ a, b ] = [ 10, 20 ];
console.log( a ); console.log( b );
Object Destructuring
Syntax
var [ var_1, var_2 ] = Object
Example
var obj = { a = 10, b = 20 };
var { a, b } = obj;
console.log( a ); console.log( b );
Array Destructuring
Syntax
var [ var_1, var_2 ] = Array
Example
var arrayOfNames = [ ‘one’, ‘two’, ‘three’ ];
var [ a, b, c ] = arrayOfNames;
console.log( a ); console.log( b );
Default values
Syntax
var [ var_1 = val_1, var_2 = val_2 ] = [ Array of values ]
Example
var arrayOfIds = [ 1 ];
var [ a = 5, b = 6, c = 7 ] = arrayOfIds;
console.log( a ); console.log( b ); console.log( c );
Ignore fields
Syntax
var [ key_1, , , key_n ] = [ Array of values ]
Example
var arrayOfIds = [ 1, 2, 3 ];
var [ a, , c ] = arrayOfIds;
console.log( a ); console.log( c );
Destructuring – Array from function response
Syntax
var [ key_1, , , key_n ] = function_name( );
Example
var arrayOfIds = function() { return [1, 2, 3 ]; };
var [ a, , c ] = arrayOfIds( );
console.log( a ); console.log( c );
Destructuring by rest params
Syntax
var [ key_1, key_2, …rest ] = array / object
Example
var [ a, b, …rest ] = [ 10, 20, 30, 40, 50 ]; // OR
({ a, …rest } = { a : 10, b : 20, c : 30 });
console.log( a ); console.log( rest );
Destructuring by computed params
Syntax
var [ key_1, key_2 ] = valuesObjectWithComputedParams
Example
var firstValue = 10;
var { a, b } = { a : firstValue, b : 20 }
console.log( a ); console.log( b );
Any Q?
Thank You

More Related Content

PPT
JAVA Variables and Operators
PPT
Jsp/Servlet
PDF
Collections Api - Java
PPT
Collection v3
PPT
JDBC
PPTX
Java 8 - Features Overview
PPT
JAVA OOP
PPT
OOP V3.1
JAVA Variables and Operators
Jsp/Servlet
Collections Api - Java
Collection v3
JDBC
Java 8 - Features Overview
JAVA OOP
OOP V3.1

What's hot (20)

PPT
Exception Handling
ODP
ES6 PPT FOR 2016
PPTX
String, string builder, string buffer
PPTX
Hash table in java
PDF
Node.js middleware: Never again!
PPT
Java Basics
PPTX
SUBQUERIES.pptx
PPT
Threads V4
PPT
Java 8 - CJ
PPT
Java Basics V3
PPTX
Inner classes in java
PPTX
Multithreading in java
PPTX
This keyword in java
PPTX
OOPS Basics With Example
PPTX
Chapter 3 servlet & jsp
PDF
Java ArrayList Tutorial | Edureka
PPTX
Recursion
PPTX
Web forms in ASP.net
PDF
itft-Inheritance in java
PPTX
9. ES6 | Let And Const | TypeScript | JavaScript
Exception Handling
ES6 PPT FOR 2016
String, string builder, string buffer
Hash table in java
Node.js middleware: Never again!
Java Basics
SUBQUERIES.pptx
Threads V4
Java 8 - CJ
Java Basics V3
Inner classes in java
Multithreading in java
This keyword in java
OOPS Basics With Example
Chapter 3 servlet & jsp
Java ArrayList Tutorial | Edureka
Recursion
Web forms in ASP.net
itft-Inheritance in java
9. ES6 | Let And Const | TypeScript | JavaScript
Ad

Similar to 5. Destructuring | ES6 | Assignment (20)

PDF
The Lesser Known Features of ECMAScript 6
PDF
Es6 to es5
PDF
Idiomatic Javascript (ES5 to ES2015+)
PPTX
ES6 and BEYOND
PPTX
Next Generation of Javascript
PPTX
Getting started with ES6 : Future of javascript
PDF
MCS First Year JavaScript ES6 Features.pdf
PPTX
Living in harmony - a brief into to ES6
PDF
Fitc whats new in es6 for web devs
PDF
What's New in ES6 for Web Devs
PDF
Es.next
PPTX
Web Host_G4.pptx
PDF
React Native Evening
PPTX
Getting started with ES6
PDF
Ignite es6
PDF
The Beautiful Simplicity of ES2015
PDF
Node Boot Camp
PDF
Internal workshop es6_2015
PDF
ECMAScript 6 Review
PPTX
React Js Training In Bangalore | ES6 Concepts in Depth
The Lesser Known Features of ECMAScript 6
Es6 to es5
Idiomatic Javascript (ES5 to ES2015+)
ES6 and BEYOND
Next Generation of Javascript
Getting started with ES6 : Future of javascript
MCS First Year JavaScript ES6 Features.pdf
Living in harmony - a brief into to ES6
Fitc whats new in es6 for web devs
What's New in ES6 for Web Devs
Es.next
Web Host_G4.pptx
React Native Evening
Getting started with ES6
Ignite es6
The Beautiful Simplicity of ES2015
Node Boot Camp
Internal workshop es6_2015
ECMAScript 6 Review
React Js Training In Bangalore | ES6 Concepts in Depth
Ad

More from pcnmtutorials (17)

PPTX
12. Map | WeakMap | ES6 | JavaScript | Typescript
PPTX
11. Iterators | ES6 | JavaScript | TypeScript
PDF
10. symbols | ES6 | JavaScript | TypeScript
PPTX
8. Spread Syntax | ES6 | JavaScript
PPTX
7. Rest parameters | ES6 | JavaScript
PPTX
6. Default parameters | ES6 | JavaScript
PPTX
4. Template strings | ES6
PPTX
3. Object literals | ES6 | JSON
PPTX
2. Classes | Object Oriented Programming in JavaScript | ES6 | JavaScript
PPTX
1. Arrow Functions | JavaScript | ES6
PPTX
Decorators | TypeScript | Angular2 Decorators
PPTX
Web workers | JavaScript | HTML API
PPTX
Declaration merging | Typescript
PPTX
Module resolution | Typescript
PPTX
Material design in android L developer Preview
PPT
data structure, stack, stack data structure
PPTX
1.introduction to data_structures
12. Map | WeakMap | ES6 | JavaScript | Typescript
11. Iterators | ES6 | JavaScript | TypeScript
10. symbols | ES6 | JavaScript | TypeScript
8. Spread Syntax | ES6 | JavaScript
7. Rest parameters | ES6 | JavaScript
6. Default parameters | ES6 | JavaScript
4. Template strings | ES6
3. Object literals | ES6 | JSON
2. Classes | Object Oriented Programming in JavaScript | ES6 | JavaScript
1. Arrow Functions | JavaScript | ES6
Decorators | TypeScript | Angular2 Decorators
Web workers | JavaScript | HTML API
Declaration merging | Typescript
Module resolution | Typescript
Material design in android L developer Preview
data structure, stack, stack data structure
1.introduction to data_structures

Recently uploaded (20)

PDF
Addressing The Cult of Project Management Tools-Why Disconnected Work is Hold...
PDF
Upgrade and Innovation Strategies for SAP ERP Customers
PPTX
Oracle E-Business Suite: A Comprehensive Guide for Modern Enterprises
PDF
Why TechBuilder is the Future of Pickup and Delivery App Development (1).pdf
PDF
Internet Downloader Manager (IDM) Crack 6.42 Build 42 Updates Latest 2025
PDF
Adobe Premiere Pro 2025 (v24.5.0.057) Crack free
PDF
How to Choose the Right IT Partner for Your Business in Malaysia
PDF
Design an Analysis of Algorithms II-SECS-1021-03
PPTX
Agentic AI : A Practical Guide. Undersating, Implementing and Scaling Autono...
PDF
System and Network Administraation Chapter 3
PDF
medical staffing services at VALiNTRY
PDF
Audit Checklist Design Aligning with ISO, IATF, and Industry Standards — Omne...
PDF
Odoo Companies in India – Driving Business Transformation.pdf
PDF
Wondershare Filmora 15 Crack With Activation Key [2025
PDF
How to Migrate SBCGlobal Email to Yahoo Easily
PPTX
Lecture 3: Operating Systems Introduction to Computer Hardware Systems
PPTX
Essential Infomation Tech presentation.pptx
PDF
Adobe Illustrator 28.6 Crack My Vision of Vector Design
PDF
PTS Company Brochure 2025 (1).pdf.......
PDF
Flood Susceptibility Mapping Using Image-Based 2D-CNN Deep Learnin. Overview ...
Addressing The Cult of Project Management Tools-Why Disconnected Work is Hold...
Upgrade and Innovation Strategies for SAP ERP Customers
Oracle E-Business Suite: A Comprehensive Guide for Modern Enterprises
Why TechBuilder is the Future of Pickup and Delivery App Development (1).pdf
Internet Downloader Manager (IDM) Crack 6.42 Build 42 Updates Latest 2025
Adobe Premiere Pro 2025 (v24.5.0.057) Crack free
How to Choose the Right IT Partner for Your Business in Malaysia
Design an Analysis of Algorithms II-SECS-1021-03
Agentic AI : A Practical Guide. Undersating, Implementing and Scaling Autono...
System and Network Administraation Chapter 3
medical staffing services at VALiNTRY
Audit Checklist Design Aligning with ISO, IATF, and Industry Standards — Omne...
Odoo Companies in India – Driving Business Transformation.pdf
Wondershare Filmora 15 Crack With Activation Key [2025
How to Migrate SBCGlobal Email to Yahoo Easily
Lecture 3: Operating Systems Introduction to Computer Hardware Systems
Essential Infomation Tech presentation.pptx
Adobe Illustrator 28.6 Crack My Vision of Vector Design
PTS Company Brochure 2025 (1).pdf.......
Flood Susceptibility Mapping Using Image-Based 2D-CNN Deep Learnin. Overview ...

5. Destructuring | ES6 | Assignment

  • 2. Agenda  Introduction  Destructuring by Declaration  Object Destructuring  Array Destructuring  Destructuring array as function response  Default Values and Ignore Variables  Destructuring by rest params  Destructuring by computed property name
  • 3. Agenda  Destructuring is an expression.  Destructuring makes it possible to unpack values from arrays, objects and variables into distinct variables.
  • 4. Destructuring by Declaration Syntax [ var_1, var_2 ] = [ val_1, val_2 ] Example [ a, b ] = [ 10, 20 ]; console.log( a ); console.log( b );
  • 5. Object Destructuring Syntax var [ var_1, var_2 ] = Object Example var obj = { a = 10, b = 20 }; var { a, b } = obj; console.log( a ); console.log( b );
  • 6. Array Destructuring Syntax var [ var_1, var_2 ] = Array Example var arrayOfNames = [ ‘one’, ‘two’, ‘three’ ]; var [ a, b, c ] = arrayOfNames; console.log( a ); console.log( b );
  • 7. Default values Syntax var [ var_1 = val_1, var_2 = val_2 ] = [ Array of values ] Example var arrayOfIds = [ 1 ]; var [ a = 5, b = 6, c = 7 ] = arrayOfIds; console.log( a ); console.log( b ); console.log( c );
  • 8. Ignore fields Syntax var [ key_1, , , key_n ] = [ Array of values ] Example var arrayOfIds = [ 1, 2, 3 ]; var [ a, , c ] = arrayOfIds; console.log( a ); console.log( c );
  • 9. Destructuring – Array from function response Syntax var [ key_1, , , key_n ] = function_name( ); Example var arrayOfIds = function() { return [1, 2, 3 ]; }; var [ a, , c ] = arrayOfIds( ); console.log( a ); console.log( c );
  • 10. Destructuring by rest params Syntax var [ key_1, key_2, …rest ] = array / object Example var [ a, b, …rest ] = [ 10, 20, 30, 40, 50 ]; // OR ({ a, …rest } = { a : 10, b : 20, c : 30 }); console.log( a ); console.log( rest );
  • 11. Destructuring by computed params Syntax var [ key_1, key_2 ] = valuesObjectWithComputedParams Example var firstValue = 10; var { a, b } = { a : firstValue, b : 20 } console.log( a ); console.log( b );