There are two new functions on the String Object: padStart and padEnd. Both functions take two arguments, a number and an (optional) string, and return a string with a minimum length of number (hereinafter referred to as minLength). The number represents the “minimum length” of the returned string. If a string’s length is less than minLength then padStart adds “padding” at the beginning of the string until the string’s length equals minLength. Calling padEnd under the same circumstance adds “padding” to the end of the string until the string’s length equals minLength. The “padding” by default is blank spaces. However, you can provide a string as the second argument and the characters of the string will be used to pad the string sequentially, potentially repeating characters if necessary or not including all characters depending on when the desired length of the returned string is reached. Here are some simple examples to illustrate syntax and return values of padStart and padEnd:
Object.values(obj) & Object.entries(obj)
Similar to Object.keys(obj), except Object.values(obj) returns an array of the given object’s (obj) values. And Object.entries(obj) returns an array of arrays with each sub-array containing a key/value pair: [ key, value]. [key, value] ].
An error will no longer be thrown when there is a trailing comma at the end of a function’s parameter or arguments list.
Object.getOwnPropertyDescriptors(obj, prop) takes an object and a property and returns all property descriptors of the given property. Object.getOwnPropertyDescriptors allows a programmer to pass down a property’s descriptor values through prototypal inheritance. Specifically when using Object.create. For instance:
Prior to ES8, Object.create would reset all descriptors to their default values. Now, creating an object with the syntax from line 9 would not allow the new object to set a name property. The name property would also delegate up to person and return ‘Sally” unless the writable descriptor is reassigned to true.
The return value is an object with the following properties: “value”, “writable”, “get”, “set”, “configurable”, and “enumerable”.
“value” is the value of the associated property (prop).
“writable” is a boolean and is true if the value of prop can be changed.
“get” and “set” are functions that serve as the getter/setter functions of prop respectively, or undefined if prop does not have getter/setter functions.
“configurable” is a boolean and if true the descriptor properties can be changed and prop can be modified/deleted from the corresponding object (obj).
“enumerable” is true if the prop will be accounted for/looped-over when a for in loop is invoked on the corresponding object (obj).
Shared Array Buffer Object
Gives the programmer the ability to control memory allocation and deallocation. Using the keyword new you can assign an array of a set size (in bytes).
newArray has a set size in memory of 10 bytes.
It is important to note that only one await happens at a time. That is, if there were more awaits on lines 4, 5, etc… then they would not execute until the first await on line 3 is resolved. If you want to await more than one promise at the same time then you must use await Promise.all();