-->

  • ES6 Array Destructuring


    ES6 Array Destructuring

     

     

    Array Destructuring


    It allows us to "unpack" arrays or objects into a bunch of variables which makes working with arrays and objects a bit more convenient.


    OR


    Array Destructuring is a way to extract values from  an array and assign them to variables in a concise manner.

    ES6 is different version of the ECMAScript specification. Which is the standard that defines the scripting language that javascript is based on.

    ES6 release on 2015 and there are so many features Arrow function, classes, let and const for variables.





    Syntax

     

     

    let [a, b] = [1, 2, 3, 4, 5, 6];
    let {name, age} = {firstName: 'atul', lastName: 'kumar', age:23};
    
    

     

    Example

     

    Actually we have used this code in reactjs called as TheArrow.jsx

     

     

    const myArray = [1, 2, 3, 4, 5];
    const [first, second, ...rest] = myArray;
    
    console.log(first);
    console.log(second);
    console.log(rest); 
    
    
    
    



     

    In this example first & second variables hold the first & second elements of the Array and the rest variables hold the remaining elements in new Array.


    Output


    ES6 Array Destructuring


     

    Disclaimer

     

    All tutorials are for informational and educational purposes only and have been made using our own routers, servers, websites and other vulnerable free resources. we do not contain any illegal activity. We believe that ethical hacking, information security and cyber security should be familiar subjects to anyone using digital information and computers. Hacking Truth is against misuse of the information and we strongly suggest against it. Please regard the word hacking as ethical hacking or penetration testing every time this word is used. We do not promote, encourage, support or excite any illegal activity or hacking.

     

  • 0 comments:

    Post a Comment

    For Any Tech Updates, Hacking News, Internet, Computer, Technology and related to IT Field Articles Follow Our Blog.