Example 1 — Wrap a String Key
Official shape: a single key becomes a one-element array.
_.toPath('key');
// → ['key']
_.toPath(0);
// → [0] How It Works
- Check type.
'key'is not an array. - Wrap once. Underscore returns
['key']. - Numbers too.
0becomes[0]for index paths. - Why. Deep helpers can always walk an array of segments.

