Obvious: for example, f(x_1,x_2) = x_1.
Not so obvious! You are looking for a space-filling curve.
this is a problem from kenneth ross's book "elementary analysis: the theory of calculus" in section 21 (metric spaces):
we say a function f maps a set E onto a set F provided f(E)=F.
1. show that there is a continuous function mapping the unit square {(x_1,x_2) in R^2: 0<=x_1<=1, 0<=x_2<=1} onto [0,1].
2. do you think there is a continuous function mapping [0,1] onto the unit square?
Obvious: for example, f(x_1,x_2) = x_1.
Not so obvious! You are looking for a space-filling curve.
Here are two pages that may help with that question.
Hilbert Curve -- from Wolfram MathWorld
Space-Filling Function -- from Wolfram MathWorld