如何在字符串中运行完整的javascript函数 [英] How to run complete javascript function inside string

查看:68
本文介绍了如何在字符串中运行完整的javascript函数的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好



我有javascript变量





Hi Everyone

I am having javascript variable


var str = "function(){alert('Hello')}";





我想在字符串中执行函数。



这是否可以执行字符串中的功能





任何建议或帮助材料将受到高度赞赏





关心



I want to execute the function inside the string.

Is this possible to execute the function inside the string


Any suggestion or helping material will be highly appreciated


Regards

推荐答案

eval("your-script");



eval()MDN [ ^ ]

[edit]添加链接[/ edit]


eval() MDN[^]
[edit]added link[/edit]


这篇关于如何在字符串中运行完整的javascript函数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆