Inbound plays

Basketball Hoop

Basketball Hoop

If a player is out of bounds and instead of passing the basketball inbounds they decide to pass it to a player who is also out of bounds.

Is this a legal play?

What is the play called?