Chapter 4data Structures: Objects And Arrays
To discover out what properties an object has, you can use the Object.keys function. You give it an object, and it returns an array of strings—the item’s property names. A set of every day log entries can be represented as an array. But the entries do not encompass only a quantity or a string—each entry needs to store an inventory of actions and a Boolean worth that signifies whether or not Jacques became a squirrel or not.
Ideally, we wish to group these collectively into a single worth and then put those grouped values into an array of log entries. Both string and array values contain, along with the size property, numerous properties that maintain operate values.
The types of values discussed in earlier chapters, corresponding to numbers, strings, and Booleans, are all immutable—it’s impossible to vary values of those varieties. You can combine them and derive new values from them, however if you take a selected string value, that value will all the time stay the identical. If you could have a string that incorporates “cat”, it’s not attainable for different code to alter a character in your string to make it spell “rat”.