Pen Settings

HTML

CSS

CSS Base

Vendor Prefixing

Add External Stylesheets/Pens

Any URL's added here will be added as <link>s in order, and before the CSS in the editor. If you link to another Pen, it will include the CSS from that Pen. If the preprocessor matches, it will attempt to combine them before processing.

+ add another resource

JavaScript

Babel is required to process package imports. If you need a different preprocessor remove all packages first.

Add External Scripts/Pens

Any URL's added here will be added as <script>s in order, and run before the JavaScript in the editor. You can use the URL of any other Pen and it will include the JavaScript from that Pen.

+ add another resource

Behavior

Save Automatically?

If active, Pens will autosave every 30 seconds after being saved once.

Auto-Updating Preview

If enabled, the preview panel updates automatically as you code. If disabled, use the "Run" button to update.

Format on Save

If enabled, your code will be formatted when you actively save your Pen. Note: your code becomes un-folded during formatting.

Editor Settings

Code Indentation

Want to change your Syntax Highlighting theme, Fonts and more?

Visit your global Editor Settings.

HTML

              
                <html>
  <head></head>
  <body>
    <div class="container" id="container">
      <div class="app" id="app">
        <h2>Javascript: ES6/ES2015: Demonstration of Destructuring Assignment.</h2>

        <ol>
          <li>
          Destructuring assignment syntax is a javascript expression that makes it possible to unpack values from arrays, properties from objects, into distinct variable.
          </li>
          <li>The object and array literal expressions provide an easy way to create ad hoc packages of data.
          </li>
          <li>
            This capability is similar to features present in languages such as Perl and Python.
          </li>
        </ol>
        <p>
          <strong>
            Classification:
          </strong>
        </p>
        <ol>
          <li>
            Array Destructuring
            <ul>
              <li>
                Basic Variable Assignment
              </li>
              <li>
                Assignment Seperate From Declaration
              </li>
            </ul>
          </li>
          <li>
            Object Destructuring
          </li>
        </ol>
        
      </div>
      <div class="log" id="log"></div>
    </div>
  </body>
</html>
              
            
!

CSS

              
                
              
            
!

JS

              
                /**
* CASE-1: Destructuring Assignment Syntax
* With Arrays
*/
let a, b, rest;

//Experiment-1.1. Simple use
[a, b] = [10, 20];

logger('Value of a: ');
logger(a);

//Experiment-1.2. Spread syntax
[a, b, ...rest] = [10, 20, 30, 40, 50];

logger('Rest of data is: ');
logger(rest);

//Experiment-1.3. Missing values
[a,b,c] = [10,20];
logger(`Value of c: ${c}`);

[a,b,c] = [10,,30];
logger(`Value of b: ${b}`);
logger(`Value of c: ${c}`);

/**
* CASE-2: Destructuring Assignment Syntax
* with Objects
*/

//Experiment-2.1.: with value and missing value
({d , e} = {d : 10, f : 20});
logger(`Value of d: ${d}`);
logger(`Value of e: ${e}`);


//Experiment-2.2.: 
({g : g, h : h} = {g : 30, h : 50});
logger(`Value of g: ${g}`);
logger(`Value of h: ${h}`);
              
            
!
999px

Console