Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6755229
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T13:22:30+00:00 2026-05-26T13:22:30+00:00

I found the question here: Create GUID / UUID in JavaScript? The answer provides

  • 0

I found the question here:

Create GUID / UUID in JavaScript?

The answer provides the following JS:

function S4() {
   return (((1+Math.random())*0x10000)|0).toString(16).substring(1);
}

function guid() {
   return (S4()+S4()+"-"+S4()+"-"+S4()+"-"+S4()+"-"+S4()+S4()+S4());
}

Now, Some of this seems silly to me. Why so much repetition? I planned on using this to name file being uploaded to my server so that they didn’t override each other. This doesn’t look like it will always generate a unique number.

What is the above codes benefit over just naming the file math.random(). It doesn’t even change the seed.

Sorry, I’ve never worked with GUID / UUID ever and some of the code doesn’t really make any sense to me…

CLARIFICATION

A lot of people aren’t answering the question like I asked it. A lot of people are explaining that GUID isn’t always unique, blah blah blah. That isn’t what I’m asking. I’m asking, what was the point of using it over just math.random().

Joe seems to have given the best answer for me in the comments.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-26T13:22:31+00:00Added an answer on May 26, 2026 at 1:22 pm

    Even that answer says: “do you want actual GUIDs, or just random numbers that look like GUIDs?” Because those aren’t real GUIDs. Also from the original thread: “There’s no way to generate real GUIDs in Javascript, because they depend on properties of the local computer that browsers do not expose.” so my question is: do you need a GUID? Or just a random filename? There’s nothing magical about a GUID as a consumer, it is not how it looks, it’s how it’s generated. For a random filename, using clock ticks + a random number would be (at least as) effective…

    In your case, no reason. But if you have JS code that is talking to something that is expecting a GUID or something in that form, you would need to pass something of a similar format since you can’t generate the real thing in pure JS.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Beginners Javascript question here. I am trying to create a function that finds all
I found the answer to this question in here . that solution works great
I found a question here about blogs on software development, but I would like
I've found a similar question here , but I'm looking for more general solutions.
I can't resolve this issue, I found a similar question here but: setting the
Based on my previous question here and here , I found that I can
I haven't found this question, feel free to close if it's already up here.
Searching here I found that this question was already asked , but I think
My original question can be found here , for which I've gotten some great
Related to a question I asked earlier here , I've found a problem which

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.