enum Status {
OFFLINE,
ONLINE,
DELETED,
}
function getResult(status) {
if (status === Status.OFFLINE) {
return "offline";
} else if (status === Status.ONLINE) {
return "online";
} else if (status === Status.DELETED) {
return "deleted";
}
return "error";
}
// Enumeration values start at 0 by default
getResult(0);
getResult(Status.OFFLINE);
// you can set the default starting number (1,2,3).
enum Status1 {
OFFLINE = 1,
ONLINE,
DELETED,
}
// you can set the default starting number (0,2,3).
enum Status2 {
OFFLINE,
ONLINE = 2,
DELETED,
}
Copy the code