• Manage your services digital marketing companies in Ahmedabad

    The operator takes the rest of the things in this case strings and puts them into its own array. So for example, if we didn't initialize a cat string Let me get rid of that. Let's see digital marketing companies in Ahmedabad what our other animals looked like at that point. Save it on it again. And oh I forgot a comma. That's why it's not working. Comma run. There we go. And now other animals of course.

     

    1. It's just an array like any other. So you can use other animals Daut sees what else can we do with an array. You would like a filter search for something console log. Or rather we can return digital marketing agency something return if t is equal to snakes. Konsole that log that actually. Right. So we treat this like we do any other way because that's what it is is just an array. It's just special and the fact that we created it using this rest Operator.

     

    2. So that's pretty straightforward. We could do Konst Konst dogs or dog string cat string dot dot dot other animals equal yet another our So our lynchers is kind of unhappy doesn't digital marketing companies in Ahmedabad really understand it sometimes but let's see if our logic was sound. So we will console log dog string so log cats. Just as a sanity check here OK. Looks good.

     

    3. Now, what happens if we cancel that log. Other animals you don't need the dot dot dot because it already understands what you what your intention is here. But let's see. Let's check it out. Run and you can see that it put the rest of the things no matter digital marketing companies in Ahmedabad how many things it is, in this case, it's strung put the rest of the strings into its own array. And by the way, if you did use the dot dot dot here it's kind of neat.

     

    4. Let's observe what happens. Clear run which is kind of iterates over all of them but that's not what I intended so digital marketing companies in Ahmedabad I'm going to do that. So that's kind of cool. And like I said it just does the rest. That's why it's called the rest.

     

    5. Covered the basics of array destructuring next we'll get into another of my favorites which is objects. Destructuring and object destructuring works pretty similarly to array destructuring. It has kind digital marketing companies in Ahmedabad of a similar syntax. The difference being, of course, that is for objects not for arrays. And a quick refresher on objects.

     

    6. Let's create Konst my object equals and it's accessed via a key-value pair. So if we first name Chris last name Jones, for example, the way we can access this our object literal syntax is one way to create objects. We could also do a new object but that's kind digital marketing companies in Ahmedabad of a more roundabout way. So this is the way that it's commonly done I would say more commonly done and then if you want to access any of these key-value associations you can do so in a couple of different ways.

     

    7. You know you could do a lot of this. We can do my ARBs and give them square brackets in a string basically to search through the first name. This will give us the value associated with this key if we run it we will see. We got the value also common to see dot notation digital marketing companies in Ahmedabad which will give us the same thing which means if we want to grab these out and assign them to other variables or constants or what have you bought. That's pretty straightforward.

     

    8. Let's see the first name equals my first name Conte's last name equals my Obst last name. Now if we verify the log first name call my last name. Let's take a quick peek. Clear run. And play didn't quite get the last name yet. Try again. There we go. So as you can imagine this can get pretty tedious especially if you have some kind of complicated object with you know a whole bunch of fields that maybe we have age feet for example. So are objects getting a bit more complex for getting more entries in?

     

    9. And if we want to assign each of these to a constant or a variable of some sort starts to get pretty annoying rates of course age equals my orbs Stuart age and we can add that in here as well. It so there you go. And fortunately, we can structure these digital marketing companies in Ahmedabad to make it a bit easier to do that. So let's see what that syntax looks like and it's going to be familiar to us after seeing what arrays look like.

     

    10. So let's say Conte's and instead of square brackets like we use for arrays we use object style notation So one thing you do want to make sure is that whatever key you're trying to assign to your constant should match whatever is in the object here. Which means I'm going to want the first name last name at the age of the height.digital marketing companies in Ahmedabad that's all we have. Yeah right equals my AABs. So saves us a lot of work a lot of lines of code because you can just extract these out into these constants or variables or let statements or whatever you need.

     

    11. That's an Afrikan to lock those out. First Name Last Name age height will be able to see that it has been assigned to these constants. It's clear it will run it again and looks like it is correct. And of course, if the need to be let and this goes for arrays appears well if needs to be left it would still work the exact same way. The difference being, of course, that can be reassigned at a later time whereas Konst cannot.