i am trying to use my parent function to have a value. this is probably silly question but I haven't been able to find a straight to point tutorial on how to do it.
I know that while using prototype it is possible to
function handler (selector) {
return selector;
}
Object.prototype.alertLine = function () {
alert(this);}
handler('hello').alertLine();
and still receive an alert. but i want to know if there is a way to specify the object,sting,number in the parent function eg
function handler(selector) {
if (typeof(selector) == 'string'){
return String(selector);
}
if (typeof(selector) == 'number') {
return Number(selector);
}
if (typeof (selector) == 'object') {
return Object(selector);
}
}
handler.prototype.alertLine = function () {
alert(this);
}
handler('hello').alertLine();
I don't mind if Handler is an object or not it only matters if i am pass values using this method.
thank you in advance.