Wednesday, September 9, 2020

SPREAD OPERATOR AND DESTRUCTURING ARRAY IN REACT JS


    
       //three dots(...) is called spread operator

    // Use of spread operator in Array
    const summerFlower = ["Rose","Sunflower"];
    const winterFlower = ["Marigold","Tulip","Lily"];
    const flower = [...summerFlower, ...winterFlower];
    console.log(flower);

    // Destructuring in Array
    const [flora, ...flwr] = [...summerFlower, ...winterFlower];
    console.log(flora);
    console.log(flwr);

    // Use of spread operator in object
    const fullForm = {
        "php" : "Hypertext Preprocessor",
        "html" : "Hyper Text Markup Language"
    }
    const fullFormMore = {
        ...fullForm,
        "css" : "Cascading Style Sheet"
    }
    console.log(fullFormMore);


No comments:

Post a Comment

TODO PROJECT IN REACT JS USING ARRAY HOOK, COMPONENT AND SPREAD OPERATOR

 App.jsx import   React , {  useState  }  from   "react" ; import   TodoList   from   "./TodoList" ; const   App  = ()  ...