[js] define console in non-es5 mode (closes #3245)