怎么让一串js字符串运行下

如何让一串js字符串运行下functionres(str){}其中str是一串脚本代码str script alert( xx )$( xx ).

如何让一串js字符串运行下
function   res(str){   }
其中str是一串脚本代码   str= " <script> alert( 'xx ');$( 'xx ').innerHTML=....;... "; </script> ";
我想让str这串字符运行一下,请问res函数里应该怎么写?

[解决办法]
eval