Java vs. JavaScript Iterable Object