Review your favorite Linux distribution.
Go Back > Forums > Non-*NIX Forums > Programming
User Name
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.


  Search this Thread
Old 06-15-2009, 08:31 PM   #1
Registered: Aug 2007
Location: California
Distribution: Debian
Posts: 127

Rep: Reputation: 15
javascript - class / function in function

Hello all.

I am not sure what the benefit will be to this besides keeping is all together..?
My goal is to create a class for functions I wrote.
The functions all work together for one purpose so I would like them packaged if possible.
The only classes I know are in php so this seems a bit different to me.

I would have thought this would work.?
function myClass()
	var a = "HELLO";
	function init()
		alert("MSG: "+ this.a);


Can someone please give me a tip and maybe wirte a simple example?

Thank you,
Old 06-15-2009, 09:35 PM   #2
LQ Guru
Registered: Oct 2003
Location: Bonaire, Leeuwarden
Distribution: Debian /Jessie/Stretch/Sid, Linux Mint DE
Posts: 5,182

Rep: Reputation: 1016Reputation: 1016Reputation: 1016Reputation: 1016Reputation: 1016Reputation: 1016Reputation: 1016Reputation: 1016
I can't exactly remember where I saw it, but nested functions in PHP, in short, DON'T! If I remember correctly, it has something to do with PHP being a script language, as opposed to a compiled language.

Old 06-15-2009, 09:40 PM   #3
Registered: Nov 2006
Location: Melbourne Australia
Distribution: Centos, RHEL, Debian, Ubuntu, Mint
Posts: 128

Rep: Reputation: 16
Well, he's asking about JS.. not PHP.

some basic info:
Old 06-15-2009, 10:33 PM   #4
Registered: Aug 2007
Location: California
Distribution: Debian
Posts: 127

Original Poster
Rep: Reputation: 15
Thank you both for the reply.

jlinkels - Yes thanks, I know not do that in php, but I did not see alternative in javascript.

grizly - I skimmed through it before. I will give it a good read.

Now I see am going down the wrong path. Nesting functions I see is not the answer. It works with separate functions (non nested) and I will leave it at that for now.



Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
Calling a function in javascript mohtasham1983 Programming 4 03-04-2008 04:13 PM
help with javascript function paul_mat Programming 3 02-15-2006 12:48 PM
how pass a class to a function aditya1 Programming 2 03-08-2005 09:02 PM
function prototypes in template class' (c++) qwijibow Programming 4 12-13-2004 09:34 AM
Function Definitoin Outside Templatized Class ashwinipahuja Programming 1 06-15-2004 10:53 AM > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 04:15 AM.

Main Menu
Write for LQ is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration