var kk = document.getElementById;
kk("some_id"); // gives Uncaught TypeError: Illegal invocation in chrome
but if we do that same with user defined object it works.
var obj = {
some_function : function(a){
alert(a);
}
};
var kk = obj.some_function;
kk("hello"); // works
what is the reason for this error. i just checked in google chrome and it is not working, i came across this when i was creating a short version for document.getElementById
, by var $id = document.getElementById;
but it did not work. and one interesting thing is that here $id === document.getElementById;
(true) and typeof $id
is function.
is that because of some security reasons or something ? sorry for weak english and i m not even good at making good title for questions. thanks for answers.