How to implement this logic in javascript?
I am using javascript in my project and i am a newbie. I have a scenario
where i want to implement a Status property for my component. This Status
property show the current status of my component out of a list of
available status. For example:
I implemented in this way:
var availableStatus = [
{ Name: 'visible' },
{ Name: 'hidden' },
{ Name: 'deny' },
{ Name: 'allow' },
{ Name: 'destroy' }
];
var Status = availableStatus[0];
if(Status === availableStatus[0])
//do this
else if(Status === availableStatus[1])
//do this
...
But i feel that there should be some another better approach for this. And
this logic is dependent on array items order which may create problem in
future if array order changes. I have another logic for implement this by
using Named Array. But i dont know how.
Please can anyone give me a better suggestion to implement this kind of
scenario ??
No comments:
Post a Comment