How to set up smartphones and PCs. Informational portal
  • home
  • Programs
  • What is javascript language. Global and local variables

What is javascript language. Global and local variables

There are millions of web pages on the Internet that are hosted on sites that serve different purposes. Some are attractive and others are not.

The ones that look good, are easy to use, and are interactive enough to keep you engaged for a long time are those sites that use JavaScript. What is it for? Let's find out.

It is a multi-paradigm language, which means that it supports object-oriented, functional, and imperative programming. Although its name is suggestive of Java, its syntax is derived from the C language.

Most of the web pages are in HTML format. It is a very simple language that allows you to add various elements for a web page, which makes it attractive and increases its readability. HTML code allows inline images, colors and basic animations for web pages, thereby increasing their appearance. Using CSS(Cascading Style Sheets) provides more flexibility and reduces the overall code footprint and complexity of web pages. Thus, it becomes easier to present the page content in different devices, such as Cell Phones, tablets and desktop computers... JavaScript is mainly used to add interactive elements to web pages, making them more user-friendly and attractive. Let's see what it can do and how it is used.

What is JavaScript?

This programming language is usually executed on the client side. It is used to interact with the user. It is also used in the development of games, board and mobile applications, in building pdf documents and desktop widgets. Web browsers have built-in support for this language.

Example 1

The first example is pretty simple and is commonly used in menu items. If you move your mouse over a specific link or menu button, it changes color. This color change to user actions, can be used for various visual effects and also improve the appearance of the web page. In the example below, hover over a button of your choice and see how it changes in color.

Red
Green
Blue

Placement of the script inside the tag is allowed , but not however, this can be risky. The web browser must translate the Java Script code written by the programmer into machine code.

Tag script processed by the browser before the tag elements ... This means that the script will be defined and ready to run before anything is displayed in the web browser window.

If the script is located inside the tag , a situation may arise that the user will refer to the script before it is defined. In this case, the script simply won't work. Therefore, it is better to stick to the usual sequence.

There must also be a procedure added to the page that will run the script. It is usually found inside the element. .

The script can be run different ways, but the developer does not need to know all of them. Each script taken from the Internet and translated into HTML code implies its own startup procedure.

Examples.

1. The script is activated after clicking the mouse pointer on any element of the interface, when the user hovers the mouse pointer over it. The onClick attribute is used for this.
So in the following snippet, the onClick attribute is used for the A element:
Click here for the whatever function.

But in general, the onClick attribute is unique and can be applied to almost any element.

2. Or, the script may run after loading a web page into a browser window.
The onload attribute of the element is used to activate the script after loading the web page. as in the following example.

There are a myriad of other attributes. For example, the onMouseOver attribute, which is used to run the script after the user hovers over some interface element. Or the onMouseOut attribute - when the user moves the mouse pointer away.

Java Script and jQuery

By the way, mastering Java Script has become even easier with the advent of the jQuery library.

JQuery functions solve a lot of practical and pressing issues... Even complex scripts are easy to use.

And for the site using jQuery opens huge list plugins that can be connected to any resource, as long as Java Script is used. With help jQuery plugins you can implement with a few lines of code

  • beautiful and complex menus,
  • image galleries,
  • various page management functions.
If your site is made on CMS, then you can also embed your own scripts there. Combination simple CMS and Java Script allows you to create very beautiful, easy to implement and maintain, and also lightweight solutions for small projects.

WITH using Java Script and jQuery can turn even the simplest business card site into a bright and full-fledged resource that will be an excellent representative of a company on the vast expanses of the Internet.

Many have come across the concept of javascript (JS for short), but few seriously understood what it is?

Javascript- a programming language that allows you to use various algorithms and conditions, for example, "if-then", to create serious programs. During the development of the language, the task was to make a programming language that would be similar to Java and at the same time would not be difficult for those who had not received a programmer education.

Finding out what javascript is all about flowers, but mastering it is much more difficult. Used this programming language for applications that will be linked to the Internet and sites. Architectural features of the JS language - the presence of dynamics in typing, automatic control memory, functions are first class objects.

All browsers that we only use work with the JS programming language. Everything modern web browsers (IE, Opera, Mozila and others, endowed with special module, who is able to understand and process the commands of this language into a visual form.

JavaScript the code looks like text, but it must be ordered and formatted according to special rules. Many have called this programming language client, because it is used in the browser, and many call the browser itself "clients". This is its main difference from those languages ​​that are used on the server.

What JavaScript is used for

Let's consider the main tasks that this programming language can solve:

1. Implementation of interactions with the user in the course of his actions on the pages of the site. When filling out the registration form with errors, we receive a notification about this.

2. The behavior of the site page depends on the behavior of the user. Quite often, you can observe the following picture: if you move the cursor off the page, a subscription form appears.

3. If there are any mathematical calculations and they must be placed on the page of their site, then many use Javascript for this. When the user undertakes to fill in the fields of the page with some information, it is necessary to calculate and select the field for displaying the result.

4. Elements that move, flash and perform computational operations do not appear on the pages so easily, again, everything happens thanks to Javascript codes.

This code can be submitted in several versions - or placed a separate file or embed into the HTML code of the website page itself.

Script- this is the second name of Javascript code, many sources use it to simplify it, so if you see it, don't be alarmed.

To explore Javascript codes it is necessary to make efforts and spend time, but nothing is impossible, the main desire is. On the same Internet, there are many tutorials and video lessons on this topic... I hope that this information about what javascript is useful to you.

Top related articles