Works fine assuming that the desired element has an id, and you know what it is. No worries there is of course a great deal of other ways to go about grabbing an element as well, more on that later.
When making a complex project in which document.getElementById is going to be called many times there might be a desire to wrap the method like this.
If document.getElementById is only used once or twice there is no need, but at some point it might be a good move to do something like this.
So one of the many alternatives to getElementById is getElementsByClassName. This is a method that as the name suggests can get elements by a class name that they have assigned to them, rather than an id. This will return an HTMLcollection of each element that has the given class name.
An HTMLCollection is not an Array, but it is an Array like object, so Array methods can be used via Function.call. You might still see this used in code examples now and then, but as of late there is querySelectorAll, more on that one later.
There is also a way to get a html collection of all elements of a given tag name with document.getElementsByTagName.