How to generate id by length you need in JavaScript | The Dev Tool |

generateId() {
    const length = 8 const charset='abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789',
    let id = '';
    for (let i = 0, n = charset.length; i < length; ++i)
        id += charset.charAt(Math.floor(Math.random() * n));
    return id;

Created by: martin


This page is only partially working without JavaScript. It will show content, but the tools and interactivity cannot be shown without JavaScript enabled. Please enable JavaScript for this page. About Us