# Piccoli helper: GUID, HASH, parseConfig, format e group

> Usa le funzioni di supporto che jComponent aggiunge: id casuali, hash, stringhe di configurazione, formattazione di testo e date e raggruppamento.

Framework: jcomponent20
Product: jComponent 20 (jcomponent@20)
Language: it
Content-SHA256: f4dd009453ddc3c9fdafa5919759d1859dc32f3c5f6d5a4af3964c0ef8d2f6ff
Snapshot: c0700e321579725c5cf4f5ace1ad7d2866d1b4f93c24a63c0b41b6b7998e976c
Sources: jcomponent20@3fedd009a277f50fddc608b97afbec553b67c51b
Review: not-recorded

jComponent aggiunge alcuni helper che ti evitano di caricare una libreria di utilità:

- `GUID(length)` restituisce un id casuale; `HASH(value)` restituisce un hash numerico di qualsiasi valore
- `'key:value;key2:value2'.parseConfig()` interpreta una stringa di configurazione in un oggetto, convertendo numeri e booleani
- `'{0} is {1}'.format('a', 'b')` sostituisce i segnaposto `{index}`
- `number.format(decimals, thousandsSeparator, decimalSeparator)` e `date.format('yyyy-MM-dd')` formattano numeri e date
- `array.group('field')` raggruppa oggetti per un campo in `[{ name, items }]`
- `PARSE(json)` interpreta JSON e converte le stringhe di data in oggetti `Date`; `date.add('1 day')` sposta una data

```html public/index.html
<!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>
```
