In JavaScripts »function« has a special meaning and this line is not defined as a function.
The line is made up of several parts.
• the variable theDoc has already been set up before
• activeLayer is a property of Document
• duplicate is a method of Layer (though also of Channel, Document, PathItem)
• the stuff in the brackets are the optional arguments the method takes
You can look up the parts individually (except theDoc naturally) in the OMV.