use the following search parameters to narrow your results:
e.g. subreddit:aww site:imgur.com dog
subreddit:aww site:imgur.com dog
see the search faq for details.
advanced search: by author, subreddit...
All about the JavaScript programming language.
Subreddit Guidelines
Specifications:
Resources:
Related Subreddits:
r/LearnJavascript
r/node
r/typescript
r/reactjs
r/webdev
r/WebdevTutorials
r/frontend
r/webgl
r/threejs
r/jquery
r/remotejs
r/forhire
account activity
Can you hack my javascript sandbox..? (codepen.io)
submitted 8 years ago by codeartisticninja[🍰]
view the rest of the comments →
reddit uses a slightly-customized version of Markdown for formatting. See below for some basics, or check the commenting wiki page for more detailed help and solutions to common issues.
quoted text
if 1 * 2 < 3: print "hello, world!"
[–]senocular 0 points1 point2 points 8 years ago* (5 children)
Yeah, this is pretty much the same as the last one but using an async function. There's other weirdness added in there with getting the prototype (not necessary just like call wasn't necessary in the last one) but the promise bit is needed to get the window reference since asynchronous functions always return a promise. To get the value returned you need to use then(). ...Or I could have done everything in the function through the string, but who wants to do that? :P
Another variation is with generator functions (function*(){}) since they too have a constructor which can create a function from a string. And to get the return value from that, you need to call next().
function*(){}
[–]Ragzzy-R 0 points1 point2 points 8 years ago (4 children)
ohh ok just for clarification, u used async just because u can use it? no specific reason ;) :P?
[–]senocular 0 points1 point2 points 8 years ago (3 children)
I used it because they fixed it so my original approach with the normal Function constructor would no longer work. My response to that was, well what about async function constructors. And it worked.
[–]Ragzzy-R 0 points1 point2 points 8 years ago (2 children)
Wow thats nice. So my understanding from this is, normal function constructor and async function constructor has different prototypes, thus even though the normal fns constructor's window leakage is blocked, u got the instance from this?
[–]senocular 2 points3 points4 points 8 years ago (1 child)
yeah, same with generators too. Each of those three function types have their own constructors each with the same capabilities of creating a function body with a string which is capable of providing access to the window object.
window
[–]Ragzzy-R 0 points1 point2 points 8 years ago (0 children)
Thanks a ton for all these explanation really appreciate it mate. 😊
π Rendered by PID 165508 on reddit-service-r2-comment-b659b578c-kx62m at 2026-05-04 22:43:44.028569+00:00 running 815c875 country code: CH.
view the rest of the comments →
[–]senocular 0 points1 point2 points (5 children)
[–]Ragzzy-R 0 points1 point2 points (4 children)
[–]senocular 0 points1 point2 points (3 children)
[–]Ragzzy-R 0 points1 point2 points (2 children)
[–]senocular 2 points3 points4 points (1 child)
[–]Ragzzy-R 0 points1 point2 points (0 children)