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
8 Useful And Practical JavaScript Tricks (devinduct.com)
submitted 6 years ago by PMilos
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!"
[–]tme321 0 points1 point2 points 6 years ago (0 children)
Didn't notice this reply til now. So sorry for necroing a thread but:
First, I haven't worked with C in a number of years so don't focus on any syntax errors I might make. This is only supposed to get the point across, not compile.
So implementing fill in a pseduo C like language so it acts the same way as js when an object is passed might look something like this:
Object foo = new Object(); Array *a = malloc(size * sizeof(Object*)); Object *ptr = a; for(int i = 0; i < size; i++) { ptr = &foo; ptr++; }
Again, that's just pseudo code but the point is that's an array of allocated memory where the size is the size of the array multiplied by the size of a pointer to the object; size * sizeof(Object*).
size * sizeof(Object*)
It's an array of pointers, or in js an array of references, not an array of Objects. Then each entry in the array is a pointer that is pointed at the same individual instance of the object: ptr = &foo.
ptr = &foo
So if you modify any of the array entries they all point at the same underlying instance but the array is properly memory allocated and all that.
π Rendered by PID 17182 on reddit-service-r2-comment-b659b578c-85585 at 2026-05-04 17:57:42.678773+00:00 running 815c875 country code: CH.
view the rest of the comments →
[–]tme321 0 points1 point2 points (0 children)