Search notes:
JavaScript: eval function
eval(expr_or_stmt)
evaluates the
string expr_or_stmt
(which probably should be an expression or a sequence of statements).
It returns the value of the expression or the last statement.
The
eval
function is function that is defined in the
global object.
<!DOCTYPE html>
<html>
<head>
<meta content="text/html;charset=utf-8" http-equiv="Content-Type">
<title>eval</title>
<script type="text/javascript">
var table_, tbody_;
function eval_string(str) {
var tr = document.createElement('tr');
var td_str = document.createElement('td');
var td_eq = document.createElement('td');
var td_eval = document.createElement('td');
td_str .appendChild(document.createTextNode( str ));
td_eq .appendChild(document.createTextNode( '=' ));
td_eval.appendChild(document.createTextNode(eval(str)));
tr.appendChild(td_str );
tr.appendChild(td_eq );
tr.appendChild(td_eval);
tbody_.appendChild(tr);
}
function main() {
table_ = document.createElement('table');
tbody_ = document.createElement('tbody');
table_.appendChild(tbody_);
document.getElementsByTagName('body')[0].appendChild(table_);
eval_string("42" );
eval_string("21 * 2" );
eval_string("Boolean( 0)" );
eval_string("Boolean(42)" );
eval_string("eval(eval(40 + '+' + 2))");
eval_string("typeof(Boolean(42)) ");
eval_string("typeof(table_) ");
}
</script>
</head>
<body onload='main()';>
</body>
</html>
See also
geval(…
) to evaluate an expression in the global context.
Fatal error: Uncaught PDOException: SQLSTATE[HY000]: General error: 8 attempt to write a readonly database in /home/httpd/vhosts/renenyffenegger.ch/php/web-request-database.php:78
Stack trace:
#0 /home/httpd/vhosts/renenyffenegger.ch/php/web-request-database.php(78): PDOStatement->execute(Array)
#1 /home/httpd/vhosts/renenyffenegger.ch/php/web-request-database.php(30): insert_webrequest_('/notes/developm...', 1740537227, '18.221.100.52', 'Mozilla/5.0 App...', NULL)
#2 /home/httpd/vhosts/renenyffenegger.ch/httpsdocs/notes/development/languages/JavaScript/objects/global/function-properties/eval(98): insert_webrequest()
#3 {main}
thrown in /home/httpd/vhosts/renenyffenegger.ch/php/web-request-database.php on line 78