The Template Code widget takes template code, as in a skin's .tpl files: HTML, Smarty template tags and functions such as {jrCore_list}, and JavaScript.
Use it for content the other widgets can't make, such as a custom list layout.
Smarty treats { and } as the start and end of template tags, so JavaScript with braces can break the widget. Wrap JavaScript in {literal} ... {/literal}:
{literal}
<script>
$(function() { console.log('ready'); });
</script>
{/literal}If a widget breaks the page, use repair mode to fix it.