That is called a closure. Take a look at this article. Basically, the way you've written that function only the inside of that function can access those two variables. Also, you haven't actually called the function bark in this scenario, you just defined the function that has a name of bark. Had you written it this way...
var bark = function() {
this.animals = "Dogs";
this.sound = "Bark";
}
var myBark = new bark();
Then you could console.log the results. For instance...
console.log(myBark.animals);
console.log(myBark.sound);
Now as you can see because of the this and the new, animals and sound belong to the instance of myBark. You could also do it like this.
var bark = function() {
var animals = "Dogs";
var sound = "Bark";
this.logInfo = function() { console.log( animals + " go " + sound ); };
this.getAnimals = function() { return animals; };
this.getSound = function() { return sound; };
}
With this way you now have the variables closed off but you have access to them through these member functions. If I say...
var myBark = new bark();
I can then print stuff and get stuff like so...
myBark.logInfo();
console.log(myBark.getAnimals());
console.log(myBark.getSound());