Example analysis of dynamic function usage in javascript

  • 2020-06-12 08:30:02
  • OfStack

This article illustrates the use of dynamic functions in javascript. Share to everybody for everybody reference. The specific analysis is as follows:


<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title> Dynamic function </title>
<script type="text/javascript">
  var show = new Function("x", "y", "var sum=x+y; return sum;");
  // Pay attention to new Function  Defining dynamic functions ,F A capital 
  var result = show(3, 5);
  alert(result);
</script>
</head>
<body>
</body>
</html>

Hopefully, this article has been helpful in your javascript programming.


Related articles: