[js] use dynamic $iterator for type parameter classes (closes #2451)