[core] fix previous commit: forget the function for JavaScript, and and move it to the proper file