birguslatro: Birgus Latro III icon (Default)
Well, not "tomorrow", (as suggested as a possibility in my last post), but tonight instead. Things just seem to crop up and I've never enough time.

Anyway, one of the things I've been doing of late is working on a website, (well, page, or eventually pages of one), with a mate who's in Scotland. We'd been trying to think of something to do on the web for quite a while, (read 'a few years'), and it seems it's very hard to come up with an idea that interests someone else. The result being we're doing this thing, just to be doing something with a VPS server we share. And it'll hopefully see the light of day soon, though don't get too excited as it's kinda specialised and won't be of real use to most people.

I've found it fun, anyway. I'm mostly doing the website, which means I'm using JavaScript for the first time. (It's more app than webpage.) JavaScript hasn't proved much of a problem, though having got tired of repeating "for (var i = 0; i < whatever.length; i++) {", I looked around for a forEach function, and found it wanting. It does have a forEach method for arrays, but it only works with arrays. Most odd.

So I've come up with my own forEach function, which works with arrays, objects and strings...
Which is behind the cut as the examples make it quite long... )
This seems to work well and is a lot cleaner than your bog standard for loop, though let me know if there's any possible issues with it - or there's a better way.

Ideally you'd be able to write...
forEach(arr-obj-or-str, i) {

I don't know if it's possible to create such a function in JavaScript though.

And now to catch up on people's journals. Starting at 12:35am. Sigh...


birguslatro: Birgus Latro III icon (Default)

August 2017

  1 2345
6789 101112


RSS Atom

Most Popular Tags

Style Credit

Expand Cut Tags

No cut tags