Bash String Functions Substring Method In Javascript