[JS] Bug fixed

Encoding does not work in presence of undefined value