I was going over Javascript the good parts and I came across this example, where the author was trying to explain how to be able to call a superclass:
Object.method('superior', function (name) {
var that = this,
method = that[name];
return function ( ) {
return method.apply(that, arguments);
};
});
an example of using this code:
super_get_name = that.superior('get_name');
however chrome wouldn't recognize method
on Object. I tried doing the same thing using defineProperty but that didn't work either.. any help?
update: does this method cause any known conflicts with jQuery? As soon as i put the following at the first js file in my page:
I get this error in line 2062 in jquery-1.11.0.js:
Uncaught TypeError: Object function (name) {
var that = this,
method = that[name];
return function ( ) {
return method.apply(that, arguments);
};
} has no method 'exec'
this is the effected code:
// Filters
for ( type in Expr.filter ) {
if ( (match = matchExpr[ type ].exec( soFar )) && (!preFilters[ type ] ||
(match = preFilters[ type ]( match ))) ) {
matched = match.shift();
tokens.push({
value: matched,
type: type,
matches: match
});
soFar = soFar.slice( matched.length );
}
}
any idea what's going on?