While building up my own library for Telegram Bot API, I’ve run across the need to transmit files via multipart/form-data. Old established libraries like OkHttp or Apache Http Client already has classes for multipart data, but there is nothing like this in Java 11 new http client.

I’ve discovered a decent collection of recipes for Java 11 http client, and then I’ve used it as the foundation for this article.

Thus I choose to rewrite multipart/form-data method in Kotlin and adapt it to my project:

Here is code for Telegram bot, so you could replace token and try it yourself. Probably, it would be easier to adapt my code to your needs:


No, you can’t. I’ve got an example for you:

var a={},
b={key:'b'},
c={key:'c'};
a[b]=123;
a[c]=456;
console.log(a[b]);
console.log(a[c]);

Output of both console.log statements will be 456. To understand why it it so, we should use base Object method toString() on both objects. We will see following output:

> b.toString();
< "[object Object]"
> c.toString();
< "[object Object]"

So when you use object as a key of another object it internally converts to string with value [object Object]. So this is all equal calls:

a[b] === a[c] === a[{}] === a["[object Object]"]

But if you still want to use object as a key, you should use ES6 Maps.


Image for post
Image for post
Photo by Joshua Aragon on Unsplash

Recently I’ve dived into ECMA-262 (9th Edition / June 2018) specification and in this article I will try to explain variable hoisting using LexicalEnvironment and VariableEnvironment. This article mainly summarise answers to several StackOverflow questions and my understanding of the specification.

The difference between var and let declarations is scoping. var is scoped to the nearest function block and let is scoped to the nearest enclosing block, which can be smaller than a function block. Both are global if outside any block. Also, variables declared with let are not accessible before they are declared in their enclosing block.

Let’s review following interview…

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store