makeable / uuid-v4.js

Fast Javascript Random (RFC-4122 v4) UUIDs

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Passing 'this' to the closure

afhole opened this issue · comments

What is the purpose of passing 'this' to the closure?
The closure takes no arguments, and then just uses whatever 'this' happens to be inside that closure anyway. Am I missing something?

No reason, just an overeager editor snippet :)

Edit: scratch that - looks like its to put it in the global scope for browser usage

That's what I had thought, but in order to use the 'this' that's passed to the closure you'd have to reference it as an argument. The reference to 'this' inside the function (this.UUID) will just be whatever this is already bound to. Unless I am mistaken, which is entirely possible!

No, it looks like you are entirely correct. Its passing in the current context to the closure then completely ignoring it and relying on the leaked scope. Ill get this fixed! Good catch :)

Fixed here: 907f7eb

Awesome, thanks :)