473,503 Members | 1,803 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

how to do ENUM ?

Hi,

In vb.net it would be like :

Enum eFilterType
OpenBracketFilter = 0
ClosedBracketFilter = 1
ValueFilter = 2
CategoryFilter = 3
NotFilter = 4
OperatorFilter = 5
End Enum

How can i do that in JavaScript (not JScript) ?

Thanks

Oct 9 '06 #1
4 38039


sa*************@googlemail.com wrote:

In vb.net it would be like :

Enum eFilterType
OpenBracketFilter = 0
ClosedBracketFilter = 1
ValueFilter = 2
CategoryFilter = 3
NotFilter = 4
OperatorFilter = 5
End Enum

How can i do that in JavaScript (not JScript) ?
JavaScript 1.x does not have an enumeration data type declaration
feature. JScript.NET has one:
<http://samples.gotdotnet.com/quickstart/howto/doc/Languages.aspx#Enumeration>

--

Martin Honnen
http://JavaScript.FAQTs.com/
Oct 9 '06 #2
Thanks, but I've explicitely mentionned JavaScript, not JScript. I'm
wondering what would be the best solution to emulate an ENUM
functionnality in JavaScript, since as you pointed out, it is not
supported. Does anyone have an idea ?

Thanks
Martin Honnen wrote:

JavaScript 1.x does not have an enumeration data type declaration
feature. JScript.NET has one:
<http://samples.gotdotnet.com/quickstart/howto/doc/Languages.aspx#Enumeration>
Oct 9 '06 #3
sa*************@googlemail.com wrote:
Enum eFilterType
OpenBracketFilter = 0
ClosedBracketFilter = 1
How can i do that in JavaScript (not JScript) ?
var eFilterType = { OpenBracketFilter:0, ClosedBracketFilter:1, ... };

alert(eFilterType.OpenBracketFilter);

If that doesn't answer the question, then be more specific about exactly
what functionality of ENUM you want to emulate.

--
Matt Kruse
http://www.JavascriptToolbox.com
http://www.AjaxToolbox.com
Oct 9 '06 #4
It does answer the question actually !
Thanks a lot Matt !
var eFilterType = { OpenBracketFilter:0, ClosedBracketFilter:1, ... };

alert(eFilterType.OpenBracketFilter);

If that doesn't answer the question, then be more specific about exactly
what functionality of ENUM you want to emulate.
Oct 9 '06 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

20
4786
by: Glenn Venzke | last post by:
I'm writing a class with a method that will accept 1 of 3 items listed in an enum. Is it possible to pass the item name without the enum name in your calling statement? EXAMPLE: public enum...
21
4570
by: Andreas Huber | last post by:
Hi there Spending half an hour searching through the archive I haven't found a rationale for the following behavior. using System; // note the missing Flags attribute enum Color {
31
3563
by: Michael C | last post by:
If a class inherits from another class, say Form inherits from control, then I can assign the Form to a variable of type Control without needing an explicit conversion, eg Form1 f = new Form1();...
18
11298
by: Visual Systems AB \(Martin Arvidsson\) | last post by:
Hi! I have created an enum list like this: enum myEnum : int { This = 2, That, NewVal = 10, LastItm
2
3387
by: Dennis | last post by:
I have an enum as follows: Public Enum myData FirstData = 6 SecondData = 7 end enum Is there anyway that I can return the Enum names by their value, i.e., I want to input 6 into a function...
13
12360
by: Don | last post by:
How do I get an Enum's type using only the Enum name? e.g. Dim enumType as System.Type Dim enumName as String = "MyEnum" enumType = ???(enumName)
10
3868
by: Randy | last post by:
Hi, Can anyone point me to a complete, compilable example of Besser's ENUM++ mechanism? I downloaded it from CUJ and gave it a try but got errors just trying to compile the header enum.h. ...
1
2443
by: Randy | last post by:
Hi, I downloaded and tried the ENUM++ code from CUJ http://www.cuj.com/documents/s=8470/cujboost0306besser/ but can't even get it to compile (see following). I have also downloaded and...
2
2105
by: Randy | last post by:
Hi, I downloaded and tried the ENUM++ code from CUJ http://www.cuj.com/documents/s=8470/cujboost0306besser/ but can't even get it to compile (see following). I have also downloaded and...
34
11130
by: Steven Nagy | last post by:
So I was needing some extra power from my enums and implemented the typesafe enum pattern. And it got me to thinking... why should I EVER use standard enums? There's now a nice little code...
0
7202
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
7086
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
7280
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
1
6991
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
7460
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
3154
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
1512
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
1
736
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
380
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.