Skip to content

Instantly share code, notes, and snippets.

@djD-REK
Created September 3, 2019 15:50
Show Gist options
  • Save djD-REK/81d39bb8f5b231084f433e1e9a769c66 to your computer and use it in GitHub Desktop.
Save djD-REK/81d39bb8f5b231084f433e1e9a769c66 to your computer and use it in GitHub Desktop.
const myString = " Hello world! ";
console.log(myString.trim()); // The leading and trailing whitespace are removed: "Hello world!"
console.log(myString); // The original string remains unchanged: " Hello world! "
// String.prototype.trim() is used with a . (dot-reference operator), not:
trim(myString);
// This would result in "ReferenceError: trim is not defined"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment