[js] fix Std.string with objects that have non-function toString field (closes #3480)