Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

passing string becomes object

I'm passing with marketing.reg("bum","a","b","c"); a string to a function.

In the first scope it is still a string.

After passing to the next scope it becomes an object. How to avoid it?

    function mktg() {};
    mktg.prototype.reg = function(nameOfEvent,a,b,c) {
    //typeof a,b,c is string
            var fktn= function(a,b,c) {
                console.log(typeof a); //is object not string
                console.log( "fktn a: ",a);
            };

            $(document).on(nameOfEvent, fktn);

    };
    var marketing = new mktg;
    marketing.reg("bum","a","b","c");
like image 291
hamburger Avatar asked Feb 07 '26 17:02

hamburger


1 Answers

The variables a, b and c get replaced by the arguments of the event call "bum".

You should remove the paramters a, b and c from the function fktn.

like image 151
Martin Lantzsch Avatar answered Feb 09 '26 11:02

Martin Lantzsch



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!