It should be:

nestedFunction = function() 

Not:

nestedFunction: function()



On 21 Oct 2011, at 08:48, Rahul wrote:

> hi ,
> i was trying function scoping ,
> this is the code below,
> 
> alice = { name : "ALICE" }
> 
> Function.prototype.bind = function(scope){
>                               var _function = this;
> 
>                               return function(){
>                                       _function.apply(scope,arguments);
>                               }
>                       }
> 
> object4 = {
>       name : "OBJECT-4",
>       action : function(greeting){
>                       alert(greeting+" my name is "+this.name);
>       }.bind(alice)
> }
> 
> function fn18(){
>   object4.action("hi !!!! ");
> }
> 
> when i call function fn18() on load of page it gives an alert "
> hi !!!!! my name is ALICE",
> 
> Now if i change my code of object4 as follows
> 
> 
> 
> object4 = {
>    name : "OBJECT-4",
>    action : function(greeting){
>             alert(greeting+" my name is "+this.name);
>             nestedFunction : function(){
>               alert(greeting+" my name is "+this.name);
>             }.bind(object4);
>             nestedFunction();
>   }.bind(alice)
> }
> 
> 
> this if i call function fn18()  , it gives an error of syntax error,
> 
> why so,
> 
> waiting for your reply
> 
> -- 
> To view archived discussions from the original JSMentors Mailman list: 
> http://www.mail-archive.com/jsmentors@jsmentors.com/
> 
> To search via a non-Google archive, visit here: 
> http://www.mail-archive.com/jsmentors@googlegroups.com/
> 
> To unsubscribe from this group, send email to
> jsmentors+unsubscr...@googlegroups.com

-- 
To view archived discussions from the original JSMentors Mailman list: 
http://www.mail-archive.com/jsmentors@jsmentors.com/

To search via a non-Google archive, visit here: 
http://www.mail-archive.com/jsmentors@googlegroups.com/

To unsubscribe from this group, send email to
jsmentors+unsubscr...@googlegroups.com

Reply via email to