$old = session()->getOldInput(); // or javascript var oldInput = <?= json_encode(session()->getOldInput()); ?>; console.log("oldInput", oldInput);