About JavaScript Language

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 ?

  • Yes
  • No
See results without voting

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

2 comments

Eric Calderwood profile image

Eric Calderwood 2 years ago from USA

Is it possible (and/or practical) to learn and use JavaScript without knowing HTML and CSS? If not, should I learn HTML and CSS first before learning JavaScript or can they be learned concurrently?


sam.azgor profile image

sam.azgor 2 years ago from Bangladesh Author

thanx for comment.

the question is without knowing html/css what you do by JS ?

at least you have to make a web page to apply JavaScript.

HTML and CSS is very easy.

    Sign in or sign up and post using a HubPages Network account.

    0 of 8192 characters used
    Post Comment

    No HTML is allowed in comments, but URLs will be hyperlinked. Comments are not for promoting your articles or other sites.


    Click to Rate This Article
    working