JavaScriptのMath.random()を使用したシンプルなID生成方法
function generateId() { const characters = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789'; let id = ''; for (let i = 0; i < 10; i++) { const randomIndex = Math.floor(Math.random() * characters.length); id += characters.charAt(randomIndex); } return id; } cons>>More