Javascript examples for String Operation:String Case
Convert object camelCase keys to underscore_case
<html> <head> <meta name="viewport" content="width=device-width, initial-scale=1"> <script type="text/javascript"> window.onload=function(){//from w ww . j av a 2 s .co m function camelToUnderscore(key) { var result = key.replace( /([A-Z])/g, " $1" ); return result.split(' ').join('_').toLowerCase(); } console.log(camelToUnderscore('helloWorldWhatsUp')); } </script> </head> <body> </body> </html>