Management of "Enum" in javascript? [closed]

2

I'm developing something in JS and I need to sort data as static variables in remember a way to do this in java with the Enum , the thing I investigate is that there are no enum in js (?), so try to create an object

var baseValue = {
  kb = 1024.0,
  mb = 1048576,
  gb = 1099511627776
};

(it should be clear that I have not worked much this in JS )

I try to get one of the values like this

alert(baseValue.kb);

but I get the error Invalid shorthand property initializer

    
asked by theboshy 03.10.2017 в 17:17
source

1 answer

2

What you are really doing is defining an object with properties and syntax to specify the properties in the definition of the object in javascript is with : not with = :

var baseValue = {
  kb : 1024.0,
  mb : 1048576,
  gb : 1099511627776
};

console.log(baseValue.kb);
    
answered by 03.10.2017 / 17:19
source