Subtitle - 2022-09-03T214014.128

You might also like

Download as txt, pdf, or txt
Download as txt, pdf, or txt
You are on page 1of 1

Have you ever needed to apply

the formatting of text in a word processor from one portion of text to another. In
essence you are copying the properties
from some text that is already formatted and applying them to another
piece of text that you want to format. In a similar way as with text, JavaScript
objects can have properties
that define their characteristics. In this video, you will learn
how to D structure, objects and arrays and
also how to use the D structuring syntax, to extract new variables from objects and
arrays. To illustrate D structuring,
imagine that an object or an array is like a project folder that you have on
your computer with several files in it. D structuring something out of an object
or array, in this case your project folder is like copying that item from your
folder on to another location. The original item still exists
in your project folder. I just made a copy of
the original item but this copy is completely
independent of the original item. Now let's explore an example with
an existing built in math object to D Structure the value of phi from it. Let's
start by using the LET keyword and surround the uppercase Pie in curly
brackets equals math because I already know that the pie property
exists on the math object. I make a copy of it and I save
the new object in a separate variable. I name Pie. Note that I can only destruction
something that already exists on an object using faulty spelling,
including lower case won't work and will return an undefined value If I
type let open curly bracket small case pi close curly bracket equals
math pi returns as undefined. This is because there isn't a lowercase
pi property on the math object. So when I try to destroy culture it,
I get the value of undefined for the lower case pi variable. The next step is to
confirm that all caps
pi variable has the identical value and data type as math dot pi by using the
triple equal strict comparison operator. This will return a value of true to
prove that the D structured property and the original property
are in no way connected. I update the value of
the pie variable to be one. By Typing Pi equals one. I can now compare all caps pie
and
math dot pi again by typing pie, triple equal sign, math dot pi, thus
getting back the boolean value of false. It's clear that these two
are no longer the same. The only reason why this worked is because
the original property on the object and the D structured value
are not connected in any way. In other words, there's no connection
between the d structured variable and the source property on the given object. In
this video, you covered how to de
structure objects and erase and also how to use the D structuring syntax to extract
new variables from objects and arrays

You might also like