must use "var" to declare a variable?

must use "var" to declare a variable?

must use var to declare a variable or just type the variable only?

example:

var myvar = this.val();

or

myvar = this.val();

What is the right to use?

I tested both and it worked, but it may be that some of the two is the safest and most advisable to use.