There is an important and also useful difference between those syntaxes.
Encapsulation
In OOP it is very useful to use encapsulation, which is a mechanism for restricting access to other objects. The difference between public and private vars/functions in javascript could stated like this:
function Color(value)
{
// public variable
this.value = value; // get from arguments
// private variable
var _name = "test";
// public function
this.getRandomColor = function( )
{
return Math.random() * 0xFFFFFF;
}
// private function
function getNiceColor()
{
return 0xffcc00;
}
}
Testing public
The public variables and functions inside the a color-instance are accessible:
// create instance of Color
var color = new Color(0xFF0000);
alert( color.value ); // returns red color
alert( color.getRandomColor() ); // returns random color
Testing privates
Private variables and functions cannot be accessed from the color-instance:
var color = new Color(0x0000FF);
alert( color.getNiceColor() ); // error in console; property does not exist, because function is private.
alert( color._name ); // error in console; property does not exist, because variable is private.
NOTE
It could be better to use good-old prototypes when using public functions, because this method of coding could cause problems with inheritence.