Sure, here's a simple function in JavaScript that would accomplish this:


function isPalindrome(str) {
  // Remove any non-alphanumeric characters and convert the string to lower case
  str = str.replace(/[\W_]/g, '').toLowerCase();

  // Compare the string with its reversed version
  return str === str.split('').reverse().join('');
}

You can use this function like so:

console.log(isPalindrome("racecar"));  // Returns true
console.log(isPalindrome("hello"));    // Returns false

This function works by first removing any non-alphanumeric characters from the string and converting the remaining characters to lower case. It then compares this processed string to the reverse of itself. If the two match, then the string is a palindrome, and the function returns true. Otherwise, it returns false.