Assigning document.getElementById to another function

Posted by Andreas Grech on Stack Overflow See other posts from Stack Overflow or by Andreas Grech
Published on 2010-04-16T22:42:39Z Indexed on 2010/04/16 22:53 UTC
Read the original article Hit count: 289

I am trying to do the following in JavaScript:

var gete = document.getElementById;

But I am getting the following error (From FireBug's Console):

uncaught exception: [Exception... "Illegal operation on WrappedNative prototype object" nsresult: "0x8057000c (NS_ERROR_XPC_BAD_OP_ON_WN_PROTO)" location: "JS frame :: http://localhost:8080/im_ass1/ :: anonymous :: line 15" data: no]

Now obviously I can wrap the function as follows:

var gete = function (id) {
    return document.getElementById(id);
};

But what is the reason I'm getting the above exception when assigning the function to another name?

© Stack Overflow or respective owner

Related posts about JavaScript

Related posts about first-class-functions