What’s new in Javascript?
Some of the new features are still proposal / not compatible in all browsers. So if you are playing with the code, try to use Google Chrome.
And some of them may
Private Fields
From the counterDemo class, the #counter value is private. If we try to access the #counter, then syntax error will be shown.
Big Int Multiplication
We can multiply 1234567890123456789n * 123n and obtain the correct value if we use BigInt.
Array Flat
Array.flat will convert nested array items to a flat list. By default, it will convert 1 level deep. You can use
const array = [ 1, [2 , [3 , 4 , [5 , 6 ] ]]]
array.flat(Infinity);
The output will be 1 2 3 4 5 6. if we use Infinity it will recursively convert to a flat list.
Object.fromEntries
We have use Object.entries in many cases. It will return an array from an object. Similarly, we can use the Object.fromEntries that will return the object from an array.
Recent Comments