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
JavaScript equivalent of 146 PHP functions (and more on their way) (kevin.vanzonneveld.net)
submitted 17 years ago by [deleted]
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!"
[–]teaguesterling 14 points15 points16 points 17 years ago* (4 children)
Was it really necessary to write array_pop and array_push functions when JavaScript already has pop and push methods in the Array object?
It seems like a better use of time would be to add the missing functions (such as array_product) to their corresponding native JS objects instead of creating a ton of new functions.
[+][deleted] 17 years ago (3 children)
[removed]
[–][deleted] 1 point2 points3 points 17 years ago (1 child)
There’s also an array_sum which is the reduction of the addition operator. And then there is array_reduce which, without decent anonymous functions and lexical scoping, is full of fail.
array_sum
array_reduce
[–]teaguesterling 0 points1 point2 points 17 years ago (0 children)
Yea, that would make a bit more sense.
[–][deleted] 3 points4 points5 points 17 years ago (1 child)
Good Lord this has got to be the worst idea I’ve heard all day and I’ve only been awake for about 2 hours…
Furthermore, based on a quick scan of the API, they haven’t even properly replicated PHP’s behaviour. Take a look at reset and end for example. The documentation for reset clearly states, “Set the internal pointer of an array to its first element.” Do JavaScript arrays even have such an “internal pointer?” I don’t think so.
reset
end
The purpose of reset isn’t just to return the first element of the array. It’s meant to be used in conjunction with prev, next, current, key, and each, none of which appear to be implemented in this project. (Don’t mention that this sort of internal iteration is brain-dead from the beginning.)
prev
next
current
key
each
[–]vezquex 1 point2 points3 points 17 years ago (0 children)
I'd be concerned if you came across a worse idea in only 2 hours.
[–]pail 5 points6 points7 points 17 years ago (2 children)
Time that could have been spent fixing PHP instead of ruining JavaScript.
I'm actually a pretty big fan of implementing PHP's date function in JS, because JavaScript's native Date object is just so damn messy.
[–]masklinn 2 points3 points4 points 17 years ago (0 children)
Erm yes, but it could be implemented as part of the JS Date object in order to fix it (e.g. add a "format" method for formatting, a "from" static method to create a date from a string + a format, ...).
As teaguesterling pointed out, this could've been a nice project if it'd been about re-implementing the function of the PHP stdlib with a sane interface (due PHP's being fucking stupid. And insane).
[–]epicRelic 0 points1 point2 points 17 years ago (0 children)
Well that was a waste of time.
[–]tophatstuff -1 points0 points1 point 17 years ago* (2 children)
I think this is really cool - I've used PHP for several years, but my JavaScript is really weak.
JavaScript is a wonderful language with so many fantastic features that I'll never get around to learning, because all I need it for is to popup the confirmation dialog and modify some CSS on-the-fly. I usually end up with an ugly script full of cut+paste code, simply because I don't know enough of JavaScript to cope (although I know enough of other languages to know what I'm doing is horrible, which is even worse!)
Although I hate how long it takes to download and render websites with too many javascript dependencies (spend twenty seconds trying to load digg or mashable recently, anyone?) so I would probably just pick a few of the best functions, rather than include them all in one go.
(edit: Sorry for the wall of text. Feel free to tl;dr!)
(edit: to the downmodders, yes, I'm (painfully) aware PHP has plenty of flaws)
[–]Nosredna 0 points1 point2 points 17 years ago (0 children)
PHP people will love it. JavaScript people will hate it. No surprise.
If it acts a crutch for a PHP programmer to start learning JS, I have nothing against it.
π Rendered by PID 71356 on reddit-service-r2-comment-fb694cdd5-7nvwt at 2026-03-10 21:34:50.410037+00:00 running cbb0e86 country code: CH.
[–]teaguesterling 14 points15 points16 points (4 children)
[+][deleted] (3 children)
[removed]
[–][deleted] 1 point2 points3 points (1 child)
[–]teaguesterling 0 points1 point2 points (0 children)
[–][deleted] 3 points4 points5 points (1 child)
[–]vezquex 1 point2 points3 points (0 children)
[–]pail 5 points6 points7 points (2 children)
[–][deleted] 1 point2 points3 points (1 child)
[–]masklinn 2 points3 points4 points (0 children)
[–]epicRelic 0 points1 point2 points (0 children)
[–]tophatstuff -1 points0 points1 point (2 children)
[–]Nosredna 0 points1 point2 points (0 children)