JavaScript for WordPress › Forums › Vanilla JavaScript › is for loop better than for of ? › Reply To: is for loop better than for of ?
April 15, 2017 at 5:49 pm
#25767
Zac Gordon
Keymaster
I used the for loop just to make it as a simple as possible in terms of using Vanilla JavaScript.
While technically the for loop may be a little faster to execute, the for in or for of loops are much cleaner to write.
I would suggest using for in and for of when they are appropriate.
As for your question about for in not working, it should work if you’re using it correctly. I don’t see an example of for in above tho, only for of. Is that what you meant?