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");
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With