---
url: /docs/guide/usage/linter/rules/oxc/bad-char-at-comparison.md
---

### What it does

This rule warns when a character accessed with `charAt`, `at`, or bracket notation is
compared with a string of length greater than 1.

### Why is this bad?

Character access returns a string of length at most 1. If the return value is compared with
a string of length greater than 1, the comparison will always be false.

### Examples

Examples of **incorrect** code for this rule:

```javascript
a.charAt(4) === "a2";
"abc".at(4) === "a2";
"abc"[4] === "a2";
a.charAt(4) === "/n";
```

Examples of **correct** code for this rule:

```javascript
a.charAt(4) === "a";
a.charAt(4) === "\n";
```

## How to use

## Version

This rule was added in v0.0.22.

## References
