javascript: fix ptr handling