Some basic on Javascript that not all programmers are aware

These are some of the JavaScript way of writing that one usually do not know by learning on some basic web site such as

Declaring many variables at once

You can declare many variable at once by doing the following,

var test,test1,test2,test3,test4
var test=1,test1=2,test2=3,test3=4,test4=5

Assignment operator shortcuts

you can do a assignment operator in short instead of writing long code.

x+3=x -> 1+=3
x-4=-x -> x-=4
x*1=x -> x*= 1
x/1=x -> x/=1
x+1=x -> x++
x-1=x -> x--

The "with" statement

The 'with' statement basically help you reduce some code. The meaning of with can be read as 'with this'. For example,

<script type="text/javascript">
document.write('Hi there, how are you?")
document.write('Fine, thanks. And you?')

You can write as

<script type="text/javascript">
write('Hi there, how are you?")
write('Fine, thanks. And you?')

By using the 'with' statement, everything that falls inside of its brackets ({ }) default to the object specified in it's parameter. That way, you only need to type the object name once.