Some common java script functions

The eval() function evaluates a string and executes it as if it was script code.

<script type=”text/javascript”>

eval(“x=10;y=20;document.write(x*y)”);
document.write(“<br />”);

document.write(eval(“2+2”));
document.write(“<br />”);

var x=10;
document.write(eval(x+17));
document.write(“<br />”);

</script>

Output:

200

4

27

Using html control

document.getElementById(‘controlId’).value

URL-Encoding

escape(“It’s me!”) // result: It%27s%20me%21

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: