Today we will learn about the de structuring in java script. Let us take a simple example how a regular array is defined
var capital =["Delhi","London","Paris"] now if we want to access London then we have to pass the value as capital[1].
Now an alternate way and when we want to remember the names rather than indexes to query an array is var [India,England,France] = ["Delhi","London","Paris"]
In here in order to access London we can say console.log(England) and the output would be London
This is a simple way to de structure an array. Similarly we can do the same the for an object as well
If we have multiple values in an object
Now if we have to get mango details then it should be console.log(myfav[1]);
Now applying destructuring here
In the above example we can rename the attributes in following way
The result here would be apple
nice post.
ReplyDeleteSap ABAP On Hana online online training
SAP Grc online training
SAP Secrity online training