Nested Functions RRS feed

  • Question

  • I need to nest some functions in a main function in JavaScript. It's structure is like this --

    function a(x) {
        this.b = function(y) {
            console.log(x + ' ' + y);

    When I call it, i.e, a().b(), I have to do this --

    new a(x).b(y);

    But I guess how the makers of jQuery managed to do it without the 'new' keyword and directly using '$' as function name. (if I'm not wrong).

    So, I'm searching for a way of doing so "without using 'new' keyword and I need it seriously, any help would be very appreciated.

    Mayank Mathur

    • Edited by _M . M_ Friday, May 13, 2016 4:25 PM Now I need the help more urgently.
    Tuesday, April 26, 2016 3:00 PM