Comparison of the text retrieved from getAttribute with the variable

why retrieve the text with the getAttribute method returns a different string than the same text assigned to the variable ?

<!DOCTYPE html>
<html>
  <body>
    <div name="other" txt="textttestnparsetnewnline">test</div>
  </body>
</html>

var d1 = document.querySelector("[name=other]");
var text = d1.getAttribute("txt");

var text2 = "textttestnparsetnewnline";
console.log(text.localeCompare(text2));
console.log(text);
console.log(text2);

textttestnparsetnewnline != textttestnparsetnewnline

https://jsfiddle.net/qva3ubjt/