Войдите или зарегистрируйтесь
Вы сможете писать комментарии и посты, ставить лайки и другое
Поиск
Тёмная тема

Misleading naming in JavaScript: atob() and btoa()

11 дн. назад
JavaScript has two globally available metods for working with Base64: atob() and btoa(). Their names clearly look like they were borrowed from older languages. In C, for instance, the standard library includes functions like atoi and atof:

#include <stdlib.h>

char str[] = "123";
int num = atoi(str); // 123

atoi means ASCII to integer, and atof means ASCII to float (though in reality it returns a double).

So what do you think the atob function does in JavaScript? ASCII to Base64? In other words, converting a regular string into a Base64 string? Nope! It does the exact opposite: it converts a Base64 string into a "regular" string. And btoa, in turn, converts a regular string into Base64!

console.log(btoa('Famabara')); // 'RmFtYWJhcmE='
console.log(atob('RmFtYWJhcmE')); // 'Famabara'

Who thought it was a good idea to swap the names like that? Love JS.
+1
13

A Naked Gun (2025) reference to the TV series Police Squad! (1982)

недавно
The new Naked Gun has one subtle reference that doesn't point back to the original film trilogy, but much further - to the TV series that served as the blueprint for all three movies. In other words, it's a nod to Police Squad! from 1982.

In the final scene of the new film, everyone around the main characters suddenly freezes, while the protagonists themselves are confused about what's happening - yet they're still able to move:
This is a direct callback to the endings of every episode of "Police Squad!". That exact gag happened each time - for example, here's how episode two ends:
Показать полностью...
+2
11

Sometimes restrictions create beauty in architecture

недавно
Restrictions don't always lead to something bad. Let's look at the Blue Mosque in Istanbul - it is adorned with stunning patterns, yet there are no images of people or other living beings, because this is prohibited by Islamic norms. The restriction influenced the architecture, resulting in interiors like these:
Or take Amsterdam as an example. At one time, taxes in the city depended on the width of a building's façade, so future homeowners constructed rather narrow but tall houses. As a result, a distinctive Amsterdam architectural style emerged.
Показать полностью...
+2
7