I\'ve tried two ways to declare a member function in JS:
function init() { var name = \"Mozilla\"; function displayName() { alert(name);
In your first method:
function init() { var name = "Mozilla"; function displayName() { alert(name); } } a = new init(); a.displayName()
function displayName(){} only can be called in init(), it's like private function, so can not be used as a public function of the object(init())