(a)
In a juvenile court hearing which is based upon a petition that alleges that the minor upon whose behalf the petition is being brought is a person within the description of Section 602, the prosecuting attorney shall appear on behalf of the people of the State of California.
(b)
In a juvenile court hearing which is based upon a petition that alleges that the minor upon whose behalf the petition is being brought is a person within the description of Section 601 and the minor who is the subject of the hearing is represented by counsel, the prosecuting attorney may, with the consent or at
the request of the juvenile court judge, or at the request of the probation officer with the consent of the juvenile court judge, appear and participate in the hearing to assist in the ascertaining and presenting of the evidence. Where the petition in a juvenile court proceeding alleges that a minor is a person described in subdivision (a), (b), or (d) of Section 300, and either of the parents, or the guardian, or other person having care or custody of the minor, or who resides in the home of the minor, is charged in a pending criminal prosecution based upon unlawful acts committed against the minor, the prosecuting attorney shall, with the consent or at the request of the juvenile court judge, represent the minor in the interest of the state at the juvenile court proceeding. The terms and conditions of such representation shall be with the consent or approval of the judge of the juvenile court.