← Back

no-use-before-define warning

Prevents use of an identifier that has not yet been declared

Examples

❌  Incorrect

alert(a);
const a = 10;

f();
function f() {};

function g() {
    return b;
}
const b = 1;

✅  Correct

const a = 10;
alert(a);

function f() {};
f();

const b = 1;
function g() {
    return b;
}