I think it’s a convention taken from math notation conventions.

I is short for “index” for a traditional for loop for mapping over an array and looking up by index. J comes after I and is used for nested loops so it doesn’t shadow the outer I.

Is it for “index” or “iterator”?

Darohan
bot account
link
fedilink
21Y

yes

I believe index for the classical need to iterate through an array. E.g.

for (i = 0; I <= arr.length; i++) { var thing = arr[i] … }

So to me it stands for “index” for array lookup.

Before map and iterators were implemented in a lot of languages, this was the defacto way to iterate a list. At least this is how I learned it in java/c back in the day. Nowadays I think most OOP languages including java have implemented the “for … in …” Syntax or similar which deprecates this convention.

index and jindex

jorge
link
fedilink
11Y

jndex

Create a post

Post funny things about programming here! (Or just rant about your favourite programming language.)

Rules:

  • Posts must be relevant to programming, programmers, or computer science.
  • No NSFW content.
  • Jokes must be in good taste. No hate speech, bigotry, etc.
  • 1 user online
  • 54 users / day
  • 172 users / week
  • 445 users / month
  • 2.42K users / 6 months
  • 1 subscriber
  • 1.61K Posts
  • 35.6K Comments
  • Modlog