Install dependencies
yarn
Run code
yarn dev
When the value is defined but not used anywhere.
- not exported and not imported
- not exported and not used in the file/module
Code that's not reachable in the scope.
- Code after a return statement
function test() {
return 1;
// this constant is not reachable
const a = 'not reachable';
}
- Code that is in a unreachable branch (if statement, ternary)
if (true) {
console.log('hey!');
} else {
// this console.log is not reachable
console.log('not reachable');
}
When we store data in a variable but this assignment didn't have a real effect because the same variable will be assigned later and the current value is not used for anything.
function test() {
let a;
a = 1; // this is a dead store
a = 2;
return a;
}