If you want to mess around with JS in your browser I use JSfiddle.
But if you are looking to write out more extensive code use an IDE (integrated development environment)
Komodo Edit is the free version of Komodo IDE. It is also used for other languages besides JS. It takes a bit to figure out the interface but after you get going it works well.
Thanks a ton ,
and i have a next question
which one should i use to draw things like eg.(shapes,line,animation) ?
I haven't gotten into animations or anything yet but I know there is a lot of free software out there for it. You can try a search in Google or hopefully someone with experience in that can comment here.