There’s no way to know whether
animals is an array, a string, a function, or something else. So how do you make sure that people use variables as they were intended?
The first and most obvious solution is to document all your types. If your program fits in one or two files, you can just check the documentation to determine any given type. But when your application spans dozens or hundreds of files, or the number of developers working on it begins to climb, this solution can quickly lead to a huge mess. When you get to this point, it’s helpful to offload “checking that function signature” to your IDE or text editor.