Javascript function scope problem...

Posted on 2009-12-16
Last Modified: 2013-11-11
I have the following code of javascript to cal a function of a component. Th problem is that when I tried to access the public function through the call: GUI_MiniCalendar.component.test() or GUI_MiniCalendar.component.viewCalendar() the functions are executed in firefox without problems, but in google chrome, ie and opera the functions aren't executed at all. What I'm doing wrong?

Ext.onReady(function() {


 GUI_MiniCalendar.component = function() {


 * Private Methods


 function viewCalendar(month,year,evt)


    alert('view calendar');



 * Public methods


 return {

  viewCalendar: function(month, year, evt)


    viewCalendar(month, year, evt);


  test: function()




 }; // return




Open in new window

Question by:alborach

    Accepted Solution

    What turned out to be wrong is the name of a parameter I was sending in the request. The parameter was called 'function' and for some reason firefox make the request without problems, but opera and chrome failed to do so. Changing the name resolved the issue.
    LVL 42

    Expert Comment

    by:David S.
    Yeah, it's best to avoid using JavaScript Reserved Keywords ( ) as variable names, they may work in some cases in some browsers, but are very likely to break in others.
    LVL 29

    Expert Comment

    To that end:

    JavaScript Reserved Words
    JavaScript is very heavy-handed in its restrictions on reserved words.
    The reserved words are:
    boolean 	break 		byte
    case 		catch 		char 		class 		const 		continue
    debugger 	default 	delete 		do 		double
    else 		enum 		export 		extends
    false 		final 		finally		float 		for 		function
    if 		implements 	import 		in 		instanceof 	int 		interface
    native 		new 		null
    package 	private 	protected 	public
    short 		static 		super 		switch 		synchronized
    this 		throw 		throws 		transient 	true 		try 		typeof
    var		volatile	void
    while		with

    Open in new window


    Author Comment

    thank you both for your comments!
    LVL 29

    Expert Comment

    No worries - glad to help.

    Featured Post

    What Is Threat Intelligence?

    Threat intelligence is often discussed, but rarely understood. Starting with a precise definition, along with clear business goals, is essential.

    Join & Write a Comment

    In my daily work (mainly using, I need to write a lot of JavaScript code. One of the most repetitive tasks I do are the jQuery Ajax calls. You know: (CODE) I don't know if for you it's the same, but for me is soooo tedious to write the …
    International Data Corporation (IDC) prognosticates that before the current the year gets over disbursing on IT framework products to be sent in cloud environs will be $37.1B.
    The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)
    The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…

    754 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    14 Experts available now in Live!

    Get 1:1 Help Now