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

Sometimes restrictions create beauty in architecture

25 дн. назад
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
6

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

6 дн. назад
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
6