After extensively studying string equality in JavaScript, I naturally assumed the same rules would apply in TypeScript. However, I am encountering a perplexing issue.
I have two identical strings that do not produce equal results when using the ==
and ===
operators.
Here is the code snippet:
this.cl_applied_filts.forEach (
filt => {
console.log (`[cl-filts]`);
store.getState()._cl_filters.forEach(
f => {
// Code omitted for brevity
}
);
});
The output in the Firefox console shows:
// Output omitted for brevity
The object declaration:
export class Filter
{
checked : boolean = false;
name : string = '';
}
Despite both strings being identical down to the byte level, they are producing non-equal results. Why is this happening?
store.string_eq
is a custom function I created to compare strings byte by byte using the charCodeAt
function in order to troubleshoot this issue efficiently. However, I am still puzzled by the outcome.
EDIT: After making adjustments based on feedback, there seems to be no difference in the comparison results.