I am wodering why my code does not work when using eval, but it works without using eval() method. Can i know where am i suppose to use the eval() method and when ?
This is my code that does NOT alert :
Code:
<script type="text/javascript">
var b = {
"c" : ["red", "white", "blue"],
"d" : [2,4]
}
var e = eval("("+ b +")");
alert(e.c[0]);
</script>
This is my code that alert :
Code:
<script type="text/javascript">
var b = {
"c" : ["red", "white", "blue"],
"d" : [2,4]
}
alert(b.c[0]);
</script>