Callbacks are functions passed as arguments to other functions, executed when an asynchronous operation completes. Callback hell occurs when multiple nested callbacks make code difficult to read and maintain.
// Callback hell example
getData((err, data) => {
if (err) throw err;
processData(data, (err, processed) => {
if (err) throw err;
saveData(processed, (err, result) => {
if (err) throw err;
console.log('Data saved successfully');
});
});
});
Solutions include Promises, async/await, and modularizing code into smaller functions.