Log In


Tuesday, March 1, 2011

JavaScript Statements

Now you know what JavaScript is, let me show you some of the codes that you can use in JavaScript. In case you don't know what JavaScript is then refer to our old post which is "Introduction to JavaScript". Here are some of the statements with explanation:

Statements:

  • Input: document.write("Hello Dolly"); - Output: Hello Dolly
  • Input: document.write("<h1>This is heading #1</h1>"); - Output: This is heading #1
  • Input: document.write("<p>This is paragraph.</p>"); - Output: This is paragraph.

Comments in JavaScript:

if you are the organized type and like to keep everything organized then this is a good tip for you. Putting comments on your code really helps you because if you wanna go back to that code, you can recognize it easily. Here is the code for comments:
// - For 1 Line
/* you text, as long as you want to write the comment to be */


JavaScript Operators:

Operator
Description
Example
Result
+
Addition
x=y+2
x=7
y=5
-
Subtraction
x=y-2
x=3
y=5
*
Multiplication
x=y*2
x=10
y=5
/
Division
x=y/2
x=2.5
y=5
%
Modulus (division remainder)
x=y%2
x=1
y=5
++
Increment
x=++y
x=6
y=6
x=y++
x=5
y=6
--
Decrement
x=--y
x=4
y=4
x=y--
x=5
y=4
~~
Operator
Example
Same As
Result
=
x=y

x=5
+=
x+=y
x=x+y
x=15
-=
x-=y
x=x-y
x=5
*=
x*=y
x=x*y
x=50
/=
x/=y
x=x/y
x=2
%=
x%=y
x=x%y
x=0


Pop Up Message Box:
To Show a message box in JavaScript, this is what you should do:
alert("Your Text Belongs Here");. So why not open your JavaScript Editor and try this. If you have a website then this could be a good thing for you when you are updating the website, just put this message box like this:
alert("Hello There. At the moment we are currently updating our Website. Please check back soon for the new update! Thank you for your patience!");

Any questions? Feel free to leave a comment!

0 comments:

:a :a   :b :b   :c :c   :d :d   :e :e   :f :f   :g :g   :h :h   :i :i   :j :j   :k :k   :l :l   :m :m   :n :n   :o :o   :p :p   :q :q   :r :r   :s :s   :a :t

Post a Comment

After, you have commented, feel free to sign up for our Newsletter or become a member by registering with us! Thanks for your Comment!

Share

Twitter Delicious Facebook Digg Stumbleupon Favorites More