Javascript Data Type How to - Execute array string as Javascript method








Question

We would like to know how to execute array string as Javascript method.

Answer


<!DOCTYPE html>
<html>
<head>
<script type='text/javascript'>
<!--   ww  w .  jav a 2  s  . c  om-->
var obj = {
    clearSearch: function () {
        document.writeln('Search cleared');
    }
};
obj['clearSearch']();

</script>
</head>
<body>
</body>
</html>

The code above is rendered as follows: