how to remove whitespace only from first position of string js

JavaScript
function ltrim(str) {
  if(!str) return str;
  return str.replace(/^\s+/g, '');
}

Source

Also in JavaScript: