function doFormat(value) { switch (value) { case 0: return "low"; case 1: return "high"; default: return "unknown"; } } function doParse(value) { switch (value) { case "low": return 0; case "high": return 1; default: return -1; } } var parser = new CustomParser(doFormat, doParse); alert(parser.format(0)); //Result is "low" alert(parser.parse("ABC")); //Result is -1 alert(parser.parse("high")); //Result is 1
Name | Type | Default | Description |
---|---|---|---|
formatFunction | Function | The function called to format data. The data is passed as function argument | |
parseFunction | Function | The function called to parse data. The data is passed as function argument |
formatFunction | The function called to format data |
parseFunction | The function called to parse data |
formatFunction
The function called to format data. The data is passed as function argument |
parseFunction
The function called to parse data. The data is passed as function argument |