![](https://csdnimg.cn/release/download_crawler_static/10763703/bg14.jpg)
2
:
What Is JavaScript?
Another one of JavaScript’s main selling points is its immediacy. It lets web pages
respond instantly to actions like clicking a link, filling out a form, or merely moving
the mouse around the screen. JavaScript doesn’t suffer from the frustrating delay
associated with server-side programming languages like PHP, which rely on com-
munication between the web browser and the web server. Because it doesn’t rely on
constantly loading and reloading web pages, JavaScript lets you create web pages that
feel and act more like desktop programs than web pages.
If you’ve visited Google Maps (http://maps.google.com), you’ve seen JavaScript in ac-
tion. Google Maps lets you view a map of your town (or pretty much anywhere else for
that matter), zoom in to get a detailed view of streets and bus stops, or zoom out to get
a birds-eye view of how to get across town, the state, or the nation. While there were
plenty of map sites before Google, they always required reloading multiple web pages
(usually a slow process) to get to the information you wanted. Google Maps, on the
other hand, works without page refreshes—it responds immediately to your choices.
The programs you create with JavaScript can range from the really simple (like pop-
ping up a new browser window with a web page in it) to full-blown web applications
like Google Docs (http://docs.google.com), which let you create presentations, edit
documents, and create spreadsheets using your web browser with the feel of a pro-
gram running directly on your computer.
A Bit of History
Invented by Netscape back in 1995, JavaScript is nearly as old as the web itself. While
JavaScript is well respected today, it has a somewhat checkered past. It used to be
considered a hobbyist’s programming language, used for adding less-than-useful
effects such as messages that scroll across the bottom of a web browser’s status bar
like a stock-ticker, or animated butterflies following mouse movements around the
page. In the early days of JavaScript, it was easy to find thousands of free JavaScript
programs (also called scripts) online, but many of those scripts didn’t work in all web
browsers, and at times even crashed browsers.
Note: Ja
vaScript has nothing to do with the Java programming language. JavaScript was originally
named LiveScript, but the marketing folks at Netscape decided they’d get more publicity if they tried to
associate the language with the then-hot Java. Don’t make the mistake of confusing the two…especially
at a job interview!
In the early days, JavaScript also suffered from incompatibilities between the two
prominent browsers, Netscape Navigator and Internet Explorer. Because Netscape
and Microsoft tried to outdo each other’s browsers by adding newer and (ostensibly)
better features, the two browsers often acted in very different ways, making it difficult
to create JavaScript programs that worked well in both.