DEV Community

Cover image for typeerror: object(...) is not a function in Javascript

typeerror: object(...) is not a function in Javascript

・1 min read

In javascript browsers use javascript engine to execute the javascript code and to show errors in the console, those errors help in improving the performance of the website.
This article discusses the error “typeerror: object(...) is not a function” via example.


    <a href="javascript:;" id="test">hello</a>

<script type="text/javascript">
    document.getElementById("test").addEventListener("click", function () {
    }, false)
    function test() {
      var postTypes = new Array('hello', 'there')   
      (function() { alert('hello there') })()
Enter fullscreen mode Exit fullscreen mode


Here the programmer forgot to include semicolon
I know sometimes we don't have to include semicolons in our javascript program. But javascript requires semicolons, the thing is javascript engines insert semicolons for us on the line where it is possible.
Similarly in the above code
var a = new B(args)(stuff)()

Read more

Discussion (0)