DEV Community

Cover image for 2021 week 34, JS array & Base64 encoding. Plus Malaysian national anthem.
LongYC
LongYC

Posted on • Originally published at longyc.com

2021 week 34, JS array & Base64 encoding. Plus Malaysian national anthem.

It's the time of the year in Malaysia where the national flag can be seen everywhere, so I included a tiny history piece as the third item. The first two items are both JavaScript - one on array and another on Base64, the latter seems like it can become a whole article of its own but I kept it short.

  • JavaScript - array: [...x] will result in an array if x is iterable. Array.from(potatoes, (potato) => potato) will also result in an array if potatoes is iterable, but potatoes can also be an array-like object, e.g. {0: small, length: 1}, that allows us to create a transformed array out of an array-like object, e.g. const dinner = Array.from(potatoes, (potato) => cook(potato)).

  • JavaScript - Base64: while btoa() and atob() can be used in a browser environment to convert between binary data and Base64 encoded string, they have recently made their way to Node.js as well but use them wisely because character encoding can be tricky and Base64 encoding can easily increase the data size by a third.

  • History - Malaysia: the founding father - Tunku Abdul Rahman was part of the panel of judges that contributed to the Malaysian national anthem. "We're not going to War. We don't need this. We need a love song.", and surely enough, now the national anthem has its root in the melody of a love song.

This is my 7th weekly post since July 2021, thank you for reading and do let me know if you have any feedback by leaving a comment.

Related Links

Top comments (0)