Code snippets
Code snippets
Copy-ready answers to everyday coding questions, each with a short explanation. Laravel, PHP, JavaScript, SQL, Bash and more.
2 snippets tagged #input · Show all
JavaScript
October 14, 2026
JavaScript debounce function to limit how often a function runs
Delays a function until the user stops triggering it for a set time. Use it for search boxes, window resize and autosave so you don’t fire on every keystroke.
function debounce(fn, delay = 300) {
let timer;
return (...args) => {
clearTimeout(timer);
PHP
October 11, 2026
Laravel Request exists() vs has() vs filled() difference
exists() is an alias of has(), and both only check that the key was sent, even when its value is empty or null. Use filled() when you need a non-empty value and...
<?php
use Illuminate\Http\Request;