ArtsAutosBooksBusinessEducationEntertainmentFamilyFashionFoodGamesGenderHealthHolidaysHomeHubPagesPersonal FinancePetsPoliticsReligionSportsTechnologyTravel

About JavaScript Language

Updated on December 31, 2013

JavaScript is the programming language of the web invented for the web to add behavior and interactivity to your pages. So whether you're brand-new to JavaScript or perhaps you've been working with it on and off for years, welcome to this article.

I'm starting with the idea that you know some HTML and you know some CSS, because JavaScript is a language that works with and manipulates web pages, so I expect you know how to make web pages.

And that even if you use a WYSIWYG design program like Dreamweaver, you could, if you had to, still open up a text editor and write a basic HTML file with correctly nested elements. You don't have to be a guru. I don't expect you to be a programmer.

I don't expect you to write a transitional XHTML doctype tag from memory, but you could make a simple page that works. And that similarly, with CSS, you're good with creating and applying styles to elements, working with IDs and classes.

Source

Though if you know about programming fundamentals, variables, loops, conditions, that's very useful.

And of course, if you are an experienced programmer, that's great and welcome. Be aware that, we're going to cover the core language syntax of JavaScript, much of which is based on C. So, if you've spent several years living in C or C# or Java, yes, you're going to see some things that you already know, so expect that. JavaScript did not try and invent a new way to write an if statement. So, you might be tempted to jump ahead, but I do suggest you go through all the content. Now, I just invite you to relax and enjoy the ride early on, because even in the initial stages, you're going to see things that are different from what you expect, even in the most fundamental content, like creating variables and checking equality. And it's those little differences that the existing programmers need to focus on, the basic things you take for granted but just don't apply in JavaScript.

Source

So before we start writing some JavaScript, let's get some core concepts cleared up. It's very common to see JavaScript referred to as one of the three core languages of web pages. You have the HTML markup language for content and structure. What's your headline, how many divisions are in your page, how many paragraphs do you have, what are the contents of those paragraphs?

Then the CSS, the style sheet language, for presentation. What font does the headline use, what's the background color of the page, what's the width of the div that the paragraphs are in? And JavaScript, the programming language for your behavior and interactivity. What happens when you mouse over a menu, what happens when you type the wrong value in a form field, how long does a photo slideshow take to move from one image to the next?

JavaScript is a programming language that you'll often hear it referred to as a scripting language, and sometimes you'll hear some software developers dismiss JavaScript as just being a scripting language. And what they mean by that is that JavaScript is intentionally limited. I can't write a desktop application in JavaScript the way I might do with C++ or Java or .NET or Objective-C. JavaScript only works inside another application, the web browser. Whether that's IE or Safari or Firefox or Chrome or Opera, they all have a JavaScript engine inside them.

The operating system runs the web browser, the web browser contains a page, and the page contains the JavaScript. Now another way JavaScript is limited is that yes, it doesn't have access to the file system of the computer that it's running on. There are no words in JavaScript to open or save local files because that would be a security risk. There are no words in JavaScript to talk to a database or target a USB port. And that strikes some software developers as odd because most languages are all about input and output, and JavaScript isn't.

But of course, they're missing the point. JavaScript wasn't designed as a general purpose programming language; it was designed to manipulate web pages and it does that very well.

Now as you know, when a user opens their browser and requests a page from your web site, they're just send HTML and CSS as plain text, and you let their browser take care of interpreting and rendering it however their browser wants to, whether it's mobile, whether it's on a laptop or a desktop, and it's the same with JavaScript. JavaScript is a client-side language. It is sent to the user's computer and it runs there. That's as opposed to server-side technologies like PHP, ASP.NET, Ruby on Rails. They'll execute their code on the web server and deliver the results to the client. But with JavaScript, we just send our code to the client and we let them run it. I'm going to just interject a side note here.

JavaScript was designed to run as a scripting language using a web browser as a host program. That's why it was invented. But because it has become so popular, it has in recent years popped up as a scripting language in other applications, and even in server-side products. So you'll find it in things like Adobe Acrobat and Photoshop. JavaScript is in server-side products like Node.js and Google Apps Script.

But I'm not focusing on those uses of JavaScript. I'm talking about classic JavaScript, a client-side language used to add interactivity to web pages.

One impact of this is that because JavaScript is sent to the client, to the user, is what if the user has disabled JavaScript in their browser? Well, then we can send it over, but it won't do anything. It will be as if the JavaScript never existed. Now while this situation is less common these days than it used to be, that does mean we need to do our best to write web sites that will work whether or not JavaScript is enabled.

But yes, we want to add all of this cool functionality, but if the user doesn't have JavaScript, the web site still works. It might have more limited interactivity, but it's still perfectly usable. Now another issue can be the variety of browsers out there. Just has different browsers can render and display web pages differently, usually because they don't handle CSS exactly the same way, what happens if they handle JavaScript differently?

Well, this was one of the reasons why JavaScript had a bad reputation for a long time. Go back a few years and a lot of JavaScript had to be written to detect the browser and handle different browsers in different ways. And I'm very happy to tell you that's not really an issue anymore. There are a few edge cases, but typically we don't care what browser the user has. And to understand why, let's do a super-quick history lesson here.

Source

So JavaScript was developed in 1995 by Brendan Eich at Netscape, and it first became built into a web browser with Netscape 2. It was originally going to be called LiveScript. But because Sun's Java language was the new big deal at the time, Netscape and Sun had an agreement to rename LiveScript to JavaScript to jump on that popularity bandwagon of Java. And most people these days agree this was a bad idea and caused a lot of confusion. The two languages have nothing to do with each other. If you're brand-new to programming, they might look a little similar to you, but that's because they both really look like C.

So JavaScript is not Java. It is not a light version of Java. It was not based on Java. It doesn't matter if you know Java, and we will talk no more on the matter. Now as it became popular in Netscape, Microsoft then made their own version for Internet Explorer. They couldn't call it JavaScript, so they called it JScript, and we had more browser differences to deal with. And what happened, thankfully, then was that Netscape submitted the language to the ECMA or ECMA standards body to create an independent and officially standardized edition, and they did.
06:06 The standardized edition of this language is officially called ECMAScript, and it was first published in '97.

Do You Use JavaScript In Your Webpage ?

See results

ECMAScript. That's a name by a committee, so everyone just called it JavaScript, even though Mozilla officially owned the JavaScript name. Now ECMAScript has had a few different editions, but the one we care about is edition 3, which may surprise you. It was published way back in 1999, but that's the one that you can reliably assume full support for in every major browser,
06:40 and it's the one we're going to focus on. ECMAScript Version 5 was published at the end of 2009 and adds a few features to the language, particularly in the advanced area.

ECMAScript 5 is only now getting some support in the most recent browser versions. Adoptions of standards like this take years, and yes, at some point in the future ECMAScript 5 will be the standard, but it isn't yet. And just to let you know, compatibility was a big deal in development of ECMAScript 5, so everything we do will be compatible moving forward and it will also work in all the older browsers for many years to come. Now if you're wondering what happened to ECMAScript 4 in those ten years between edition 3 and edition 5, well it just got way out of hand and they abandoned it; ECMAScript 4 never happened.

Now, one of the benefits of having a standardized language like this is it doesn't matter if you're a Mac, PC, or Linux person, it doesn't matter if your server is Windows or Apache, if your backend is PHP or Ruby on Rails or ASP.NET or ColdFusion or none of the above; JavaScript is completely agnostic on these matters. There's no special tools required. There's no licensing needed. Sure, as with editing HTML and CSS, some applications may make our life a little easier, but all we really need is a basic text editor.

JavaScript Tutorial - Getting Started - Hello World

working

This website uses cookies

As a user in the EEA, your approval is needed on a few things. To provide a better website experience, hubpages.com uses cookies (and other similar technologies) and may collect, process, and share personal data. Please choose which areas of our service you consent to our doing so.

For more information on managing or withdrawing consents and how we handle data, visit our Privacy Policy at: https://corp.maven.io/privacy-policy

Show Details
Necessary
HubPages Device IDThis is used to identify particular browsers or devices when the access the service, and is used for security reasons.
LoginThis is necessary to sign in to the HubPages Service.
Google RecaptchaThis is used to prevent bots and spam. (Privacy Policy)
AkismetThis is used to detect comment spam. (Privacy Policy)
HubPages Google AnalyticsThis is used to provide data on traffic to our website, all personally identifyable data is anonymized. (Privacy Policy)
HubPages Traffic PixelThis is used to collect data on traffic to articles and other pages on our site. Unless you are signed in to a HubPages account, all personally identifiable information is anonymized.
Amazon Web ServicesThis is a cloud services platform that we used to host our service. (Privacy Policy)
CloudflareThis is a cloud CDN service that we use to efficiently deliver files required for our service to operate such as javascript, cascading style sheets, images, and videos. (Privacy Policy)
Google Hosted LibrariesJavascript software libraries such as jQuery are loaded at endpoints on the googleapis.com or gstatic.com domains, for performance and efficiency reasons. (Privacy Policy)
Features
Google Custom SearchThis is feature allows you to search the site. (Privacy Policy)
Google MapsSome articles have Google Maps embedded in them. (Privacy Policy)
Google ChartsThis is used to display charts and graphs on articles and the author center. (Privacy Policy)
Google AdSense Host APIThis service allows you to sign up for or associate a Google AdSense account with HubPages, so that you can earn money from ads on your articles. No data is shared unless you engage with this feature. (Privacy Policy)
Google YouTubeSome articles have YouTube videos embedded in them. (Privacy Policy)
VimeoSome articles have Vimeo videos embedded in them. (Privacy Policy)
PaypalThis is used for a registered author who enrolls in the HubPages Earnings program and requests to be paid via PayPal. No data is shared with Paypal unless you engage with this feature. (Privacy Policy)
Facebook LoginYou can use this to streamline signing up for, or signing in to your Hubpages account. No data is shared with Facebook unless you engage with this feature. (Privacy Policy)
MavenThis supports the Maven widget and search functionality. (Privacy Policy)
Marketing
Google AdSenseThis is an ad network. (Privacy Policy)
Google DoubleClickGoogle provides ad serving technology and runs an ad network. (Privacy Policy)
Index ExchangeThis is an ad network. (Privacy Policy)
SovrnThis is an ad network. (Privacy Policy)
Facebook AdsThis is an ad network. (Privacy Policy)
Amazon Unified Ad MarketplaceThis is an ad network. (Privacy Policy)
AppNexusThis is an ad network. (Privacy Policy)
OpenxThis is an ad network. (Privacy Policy)
Rubicon ProjectThis is an ad network. (Privacy Policy)
TripleLiftThis is an ad network. (Privacy Policy)
Say MediaWe partner with Say Media to deliver ad campaigns on our sites. (Privacy Policy)
Remarketing PixelsWe may use remarketing pixels from advertising networks such as Google AdWords, Bing Ads, and Facebook in order to advertise the HubPages Service to people that have visited our sites.
Conversion Tracking PixelsWe may use conversion tracking pixels from advertising networks such as Google AdWords, Bing Ads, and Facebook in order to identify when an advertisement has successfully resulted in the desired action, such as signing up for the HubPages Service or publishing an article on the HubPages Service.
Statistics
Author Google AnalyticsThis is used to provide traffic data and reports to the authors of articles on the HubPages Service. (Privacy Policy)
ComscoreComScore is a media measurement and analytics company providing marketing data and analytics to enterprises, media and advertising agencies, and publishers. Non-consent will result in ComScore only processing obfuscated personal data. (Privacy Policy)
Amazon Tracking PixelSome articles display amazon products as part of the Amazon Affiliate program, this pixel provides traffic statistics for those products (Privacy Policy)
ClickscoThis is a data management platform studying reader behavior (Privacy Policy)