How to convert a camel-case string to dashes in JavaScript? : <p>I want to convert these strings:</p>

<pre><code>fooBar
FooBar
</code></pre>

<p>into:</p>

<pre><code>foo-bar
-foo-bar
</code></pre>

<p>How would I do this in JavaScript the most elegant and performant way for any given string?</p>
