Small helpers: GUID, HASH, parseConfig, format and group
jComponent adds a few helpers that save you from loading a utility library:
GUID(length)returns a random id;HASH(value)returns a numeric hash of any value'key:value;key2:value2'.parseConfig()parses a configuration string into an object, converting numbers and booleans'{0} is {1}'.format('a', 'b')replaces{index}placeholdersnumber.format(decimals, thousandsSeparator, decimalSeparator)anddate.format('yyyy-MM-dd')format numbers and datesarray.group('field')groups objects by a field into[{ name, items }]PARSE(json)parses JSON and converts date strings intoDateobjects;date.add('1 day')moves a date
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<title>jComponent</title>
<link rel="stylesheet" href="//cdn.componentator.com/spa.min@20.css" />
<script src="//cdn.componentator.com/spa.min@20.js"></script>
</head>
<body>
<p class="out"></p>
<script>
window.sample = {
guid: GUID(12),
samehash: HASH('total') === HASH('total'),
config: 'size:3;active:true;name:Peter'.parseConfig(),
text: '{0} is {1}'.format('Total.js', 'great'),
price: (1234.5).format(2),
date: new Date(2026, 9, 16).format('yyyy-MM-dd'),
groups: [{ type: 'a', n: 1 }, { type: 'b', n: 2 }, { type: 'a', n: 3 }].group('type'),
parsed: PARSE('{"created":"2026-10-16T10:00:00.000Z"}').created instanceof Date,
tomorrow: new Date(2026, 9, 16).add('1 day').getDate()
};
</script>
</body>
</html> Try it in your browser
Edit the example and run it. It runs in an isolated frame in your browser; nothing is sent to our server.
Preview