2

I think the Function object is the only instance in the JavaScript. All the other function(){...} or var xx=function(){...} are the objects inherited from this Function object. That is the prototype based language feature. And in prototype based language there is no Class, and One of the advantages of it is the object can changed anytimes.such as add a method or add a property into it. So, I think we can treat object like a key-values collection. You can add items into it anytimes after you created it. (If I was wrong, Please correct me.)

Say you have the code:

        Function.test=function(){
            alert(Function.name);//"Function"  
            alert(Function.myName);//"fun"
        };
        Function.name="fun";
        Function.myName="fun";
        Function.test();

In the above code, all I want to do is add a test method to the Function object. There is no error found in this code. But why Function.name can not be changed?

2
  • Wat way have u defined Function()? Commented Apr 22, 2013 at 6:22
  • I don't know how to answer your question... Function is the build-in object of javascript. Commented Apr 22, 2013 at 6:39

2 Answers 2

0

First of all this property is not standard. This means that different browsers may treat it as they want. The second thing is that according to MDN it is read only.

Sign up to request clarification or add additional context in comments.

Comments

0

A page from MDN states that the name of the Function cannot be changed because it's read only.

1 Comment

Hi, @Joseph the Dreamer, IE8 can change it . It is not readonly.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.