Computers and modern gadgets

Brendan Icke
Creator of the JavaScript language

This article gives a short overview of the JavaScript language, in terms of its structure, characteristics and history. This article is intended to be read for general development and you can skip it at the initial stage of learning the JavaScript language, and return to it a little later, after reading for beginners.

JavaScript is a client-side web programming language that was created in 1995 by developer Brendan Eich.

JavaScript is commonly used for manipulating objects in various applications, but it has become most popular as one of the main languages ​​used for creating websites (and as the only client-side web programming language).

JavaScript language code, usually executed in a browser window, on an open page of the site. This is due to the fact that the default web browser has a JavaScript language interpreter, thanks to which the browser has the ability to understand and execute code written in JavaScript.

The JavaScript interpreter is part of the web browser, when the web browser opens a page of the site, the browser creates a document object model (DOM), the JavaScript interpreter accesses the DOM and thanks to this, webmasters creating various scripts (web applications) can manage and manipulate objects pages (all tags: paragraphs, headings, tables, forms, etc.).

JavaScript, like the languages ​​HTML and CSS, belongs to all mankind, it is not owned by any company or person. However, the word itself - "JavaScript", belongs to Oracle Corporation and in order not to have copyright problems, scientists developing this language in scientific documents call it ECMAscript.

History of JavaScript

In 1995, Netscape commissioned programmer Brendan Icke to create a web programming language that could be embedded in an HTML document without the need for a web server.

Other programmers participated in the project along with Brendan Ike:
Mark Anderssen (created the world's first browser - Mosaic),
Bill Joy is an employee of Sun (this company was bought by Oracle Corporation in 2010).

In those days, the most popular programming languages ​​were C and Java, so when creating JavaScript, they tried to make its syntax look a little like them.

Initially, the JavaScript language was called LiveScript, but for the sake of popularization of the language (and for marketing purposes) it was called JavaScript, which caused a lot of confusion among novice webmasters because the Java and JavaScript languages ​​​​are completely different in relation to each other (they are only slightly similar syntactically). By the way, Java itself is owned by Sun.

To further popularize the JavaScript language, it was made open, public, and then standardized. The standard itself is called ECMA-262, and the name of the JavaScript language is written in the standard as ECMAScript.

In 1996, Microsoft developed its own scripting language based on this standard and named it JScript.

The first browsers started supporting JavaScript already in 1996, these were: Netscape 2.0 and Internet Explorer 3.0

Characteristics of the JavaScript Language

Scripting - when creating programs, they do not need to be compiled (for example, in C, C ++, Pascal or Basic), you just create a script program in a text editor, and the JavaScript interpreter (which is already built into the web browser), then this script processes and executes.

Client - the script interpreter is not located on the web server (as, for example, in server languages ​​​​- PHP or Perl), but in the web browser, therefore, to create and execute JavaScript scripts, you do not need to install a web server, you only need a text editor (for example, Notepad or the now popular Sublime Text 3) and a web browser (such as FireFox, Opera, IE or Chrome, etc.).

Prototyping - JavaScript supports the creation and inheritance of objects, but it does not have classes.

If you are not yet familiar with the concept of Javascript, then about this.

In this note, I wanted to talk about what Javascript is for and what you can do with it.

Like any programming language, the main task of Javascript is to create a sequence of actions that will lead to a specific result.

These can be “if-then” conditions, loops that create a certain sequence of actions, mathematical calculations, etc.

The most important thing is that all these operations can be performed on web pages, in a browser window. Moreover, javascript can work without an Internet connection.

So, let's look at some examples that demonstrate the possibilities that can be obtained using Javascript. I conditionally sorted them into several groups so that you have a certain understanding of what Javascript does and why it is needed.

1) Mathematical operations

On web pages, very often there is a need to perform certain calculations.

For example, there are two text fields and you need to display the sum of the two numbers that are entered in the first two in the third text field.

Using Javascript, you can create a calculator and place it on a web page.

Here is an example of such a calculator:

Another situation, let's take some text string on a web page, you need to increase its size by 1.5 times. This can also be done using mathematical calculations, by multiplying the current size by a factor of 1.5.

There are a lot of tasks that require calculations in practice. Javascript allows you to do all this.

2) Data processing and validation in HTML forms

Javascript allows you to check that all required fields are filled in and the data they contain is in the correct format (for example, if numbers are required, then there should be only numbers and no letters).

This is done by Javascript without reloading the page and without even connecting to the Internet.

Before sending data to the server, they are pre-checked for Javascript. This reduces the load on the server.

3) User interactions and events

Different effects can appear on a web page, depending on what actions the user takes.

Drop-down menu on the site when hovering the mouse cursor.

When clicking on the button, hide or show some element on the page.

A pop-up window appears when the mouse cursor leaves the browser window.

Background dimming and element fade effects are implemented in Javascript.

4) Interact with HTML elements on the page and manage their content and styles.

When a certain event occurs (for example, a mouse click or any other), you can change the appearance (CSS styles) of the elements on the page.

This is all done programmatically.

You can also add some HTML tags or attributes to them, also when a certain event occurs.

5) Adding animation and various graphic effects to web pages.

Falling and moving objects. For example, snow on the site.

Smooth appearance and hiding of objects

Countdown timer

And other effects are implemented in Javascript

I've only listed a small list of Javascript features here. So that you can see everything clearly and with real examples, here is a list of sites where valid examples in the javascript language are published:

The possibilities and scope of Javascript are actually very extensive. Everything will be limited only by your imagination and creativity.

JavaScript® (often shortened to JS) is an interpreted programming language designed to interact with web pages. JavaScript runs on the client side of the web and is used to program how web pages will behave when certain events occur.

What is JavaScript?

JavaScript is a cross-platform, object-oriented scripting language that adds interactivity and responsiveness to your web pages.

JavaScript allows a website developer to control how a web page behaves. This makes JavaScript fundamentally different from HTML, the language that is responsible for the structure of a web document, and CSS, the language that shapes the appearance of web pages.

Programs written in JavaScript are called scripts. In the browser, they are connected directly to the HTML document and, as soon as the page is loaded, they are immediately executed. The process of executing a script is called "interpretation".

If the PHP script is processed on the server side using the PHP interpreter, then the JavaScript is executed in the user's browser by the JavaScript interpreter.

Today, every browser supports JavaScript, thus making it the language of the web.

In the browser, JavaScript can do everything related to manipulating the HTML document, interacting with the visitor, and, with some limitations, with the server:

  • Validate that custom HTML forms are filled in correctly.
  • Interact with webcam, microphone and other devices.
  • Change styles of HTML elements, hide, show elements, etc.
  • Display pop-ups and dialog boxes.
  • Respond to visitor actions, handle mouse clicks, cursor movements, etc.
  • Send requests to the server and download data without reloading the page.

JavaScipt is an incredibly powerful and efficient language that you should definitely try out!

JavaScript versus ECMAScript

This tutorial is written about the language known as JavaScript. However, the official standard that defines the specifications that describe the language calls it ECMAScript.

Netscape introduced the JavaScript language to Ecma International, an organization dedicated to standardizing information and communication systems (ECMA was originally an acronym for the European Computer Manufacturers Association), where it was approved as an ECMAScript standard in 1997.

This standardized version of JavaScript, called ECMAScript, works the same in all applications that support the standard. Developers can use the language's open standard to develop their own JavaScript implementation.

Formally, when developers refer to ECMAScript, they usually mean the "ideal" language defined by the Ecma standard. Most often, these two concepts are interchangeable. Therefore, when referring to the official standard in this tutorial, the name ECMAScript will be used, and in other cases, when referring to the language, JavaScript. The tutorial will also use the commonly accepted abbreviation ES5 when referring to the fifth edition of the ECMAScript standard.

JavaScript is not Java

Before you start learning JavaScript, you should understand that JavaScript is not Java. These are two completely different programming languages. JavaScript has nothing to do with the Java language other than a similar syntax.

Java is an object-oriented programming language developed by Sun Microsystems since 1991 and officially released on May 23, 1995. Java is a powerful and much more complex programming language, and you can write a wide variety of programs in it. For web pages, there is a special opportunity - writing applets.

An applet is a Java program that can be connected to HTML using the . Java applets are run using a compiler. Java applets are embedded in a web page but stored on disk as separate files. These are binaries, and if you open them, you won't see the source code for the applet.

JavaScript scripts are hosted within a web page and cannot exist separately from it. JS scripts do not require a compiler to execute, they are executed by the browser on the user's side. JS script is plain text and you can view the code with the naked eye - without any special software.

Java is a class-based language that is fast, secure, and reliable. Java's class-oriented model means that programs consist solely of classes and their methods. Class inheritance and strong typing in the Java language typically require tightly coupled object hierarchies. These requirements make Java programming more complex than JavaScript programming.

JavaScript is a lightweight programming language that has a simple syntax, specialized built-in functionality, and minimal requirements for creating objects. You do not need to declare variables, classes and methods. You don't have to worry about whether methods are public, private, or protected, and you don't have to implement interfaces. Variables, parameters, and return types of JS scripts are not explicitly typed.

What do you need to learn JavaScript?

Prior knowledge of JavaScript is not required, but since JavaScript resides within web pages and drives their dynamics, it is assumed that you are familiar with the basics of the HTML language, although the possibility of "parallel" and JavaScript is not ruled out.

Most JavaScript scripts are designed to "spice up" HTML, that is, the purpose of writing a script is to demonstrate how the page will change when the HTML tag parameter values ​​change. Put together and properly formatted, these kinds of scripts are an example of a developed web application.

Before we start writing our first JavaScript program, it is very important to make sure that all the necessary tools are set up and in place.

When learning JavaScript, it's very important to run the examples provided in each lesson, modify them, and run them again to check how well you understand the material you've learned. This requires a JavaScript interpreter. Fortunately, as you already know, every web browser includes a JavaScript interpreter.

To write and execute JavaScript programs, it is enough to install any modern Internet browser (for example, Yandex, Internet Explorer, Mozilla Firefox or Google Chrome).

Later in this tutorial, you'll see that JavaScript code can be embedded directly into HTML files, in tags, and will be executed by the browser when the HTML file is loaded. It's worth noting that you don't have to do this every time you want to test a short piece of JavaScript code.

The easiest way to experiment with JavaScript code is to use the browser's built-in Web Console tool.

As a rule, the web console can be launched by pressing the F12 key or the hot key combination - Ctrl + Shift + J . Typically, a panel or window of a typical "developer tool" opens as a separate panel at the top or bottom of the browser window, as shown in Figure 1. 1.

The panel includes many tabs that allow you to explore the structure of the HTML document, CSS styles, and more. Among them is the JavaScript Console tab, where you can enter lines of JavaScript code and execute them.

For a more detailed analysis of the program code, we need a text editor with additional functionality that simplifies writing and editing program code. As such, we will use the Notepad++ editor. If you are already using another editor and have gotten used to it, then nothing prevents you from continuing to use it.

With most of the examples given in our tutorial, you can experiment right on the site page using the built-in tool - the mini JS editor.

In order to see the result of the script execution in a new window, click on the icon , and if you have a desire to change something in the code, click on the icon

This is a normal HTML document.

Exit back to HTML

Note: In these simple JavaScript experiments, you can also omit the , and tags in your HTML file.

Learning JavaScript, like other programming languages, is not easy, but it is definitely worth the time and effort. Learning is effective when it is given not just like that, but with effort. You must make a conscious effort to learn new skills and abilities. Knowledge gained without effort is like circles on the water - very soon there will be no trace of them.

E-books, free online courses, and online problem-based learning platforms – the choice of sources of quality knowledge is almost limitless today. But how to motivate yourself to self-learning, how to learn to learn on your own?

Try following a few simple but proven tips.

You need to study little by little, but regularly. Regularity is the key to success in learning. Plan your weekdays so that you can devote at least one hour to learning JavaScript every day. Do not try to learn everything at once in a short period of time. Breaking down the self-learning process into small study sessions creates a sense of quick success and motivates you to return to learning the very next day.

The worst time to study is when you feel tired. At such moments, the main thing is not to force yourself - you will not get the expected result. The human brain cannot learn something indefinitely - it needs to be given breaks. Do the 25/5 principle. Try for yourself the practice of teaching for 25 minutes and resting for 5 minutes. Your brain will get used to such uniform loads and will work as productively as possible.

Apply the practice of remembering - the basis of learning. The more often we remember information, the longer it will be stored in our memory.

An effective recall technique is delayed recall: on one side of a card, write a question that relates to the material learned, and on the other side, write the answer to it. Learn the contents of the card, and then, after a day, try to remember the answer. If you gave the correct answer, the card can be postponed for a week until the next repetition. If you make a mistake, you must repeat the question the next day. The longer you have a chain of successful answers, the longer the interval should be before the next repetition.

In parallel with theoretical studies, constantly practice. To gain practical experience, it is enough just to write a lot and analyze examples of good code. As you work through the examples, carefully go through each line of code - you need to make sure you understand how each line works. Don't be afraid to experiment. Learn to display some data in the browser window and analyze it. For example, what and after what is displayed on the screen, did you get what you wanted, and if not, then why.

Whatever method of learning you choose, remember that it should be interesting for you and supported by practical exercises - examples are worth a thousand words. Examples are often easier to understand than a multi-page theory. So be bold! I hope that this tutorial will be a good help in your endeavors.

Still don't know what Javascript is? In this article, we can find the answer.

A bit of theory

Browsers and many other programs often use JavaScript. It is a scripting programming language. It uses a prototype-based model and is loosely typed. This language has experienced significant influence from its predecessor - ECMAScript.

The overall goal of its creation was to make it easy for non-specialists to use and easy to work with. Now JavaScript is one of the most popular programming languages ​​of its kind. Its use facilitates the fact that it is embedded in applications. JavaScript is an object-oriented language, but its functions are quite different from the functions that languages ​​of this type usually provide.

JavaScript is heavily used in web development. Drop-down menus, calendars, timers, radio buttons - these and many other elements are now implemented using the capabilities of this language.

It implements work with objects and classes differently, can automatically infer types, and supports anonymous functions. The syntax of JavaScript is between Java and C, but in functionality it is more similar to other programming languages. There are many differences in functionality between Java and JavaScript. For example, Java implements an object approach on classes, while JavaScript implements it on prototypes. The code can be embedded into a web page in specific containers.

How to enable Javascript?

- javascript code is connected in this container.
- an example of connecting the animate.js library, which is located in the same folder as this html page. src(source) is the path to the file.

JavaScript is considered safe enough, because even when its code is embedded in a web page, it does not receive high privileges and cannot work with other pages and many objects. It cannot even open an overly large program window. The main JavaScript vulnerability is cross-site scripting.

The script is embedded in the page on which the user worked and thus can capture his account. This may lead to unwanted behavior. This can also happen due to errors in the browser itself. When developing and working with scripts, it is always worth considering that the code or the program itself can fall into the hands of intruders. They can be modified or mixed up in various ways to create a spyware or malware effect.

In the same script forms, you should not enter any confidential data. All of them can be sent to a third-party server, bypassing their original destination and thus be stolen. Also, browsers can run JavaScript outside of special mode, which can lead to errors and scripts getting too much authority. This is one of the difficulties in their use. Scripts that are often run as normal applications can be Trojans.

For the full and optimal operation of web pages in a browser, it is necessary that javascript be activated in it.

What it is and how to enable it, we will explain in this article.

Pivot Table What is javascript?

JavaScript can be called a multi-paradigm language. It has support for many ways of programming. For example, object-oriented, functional and imperative.

This type of programming is not directly related to java in any way. The main syntax of this programming language is the C language, as well as C++.

The basis of browser web pages is HTML code, with the help of which programmers add various interactive elements to pages.

If javascript is disabled in the browser, interactive elements will not work.

This type of programming language appeared thanks to the joint work of Sun Microsystems and Netscape.

Initially, JavaScript was called LiveScript, but after the Java language became popular among programmers, the development companies decided to rename it.

Netscape's marketing department thought that such a name would increase the popularity of the new programming language, which, in fact, happened.

Recall that JavaScript is not directly related to Java. They are completely different languages.

JavaScript Features

This programming language has an unlimited number of possibilities due to its versatility.

The main aspects of the application are mobile applications for smartphones, interactive web pages of sites and services.

Most of the innovation came from joining the project with AJAX, which provided the features used in the language today.

To save traffic and increase ease of use, JavaScript provides the ability to change the pages of sites and services in small parts without the user noticing online.

This does not require the site to be offline while editing or adding new information.

Changes happen immediately without requiring a refresh or page reload.

The JavaScript feature can be disabled for various reasons.

It is possible that the previous user may have intentionally disabled it, as it was not required for web browsing. Also, the shutdown could happen on its own.

Disabling javascript may cause some links to fail. Below we will look at ways to enable this feature in popular browsers.

Yandex browser

To activate the JavaScript function in version 22 and below, go to the toolbar and select the menu item "Settings".

To enable javascript, go to the section "Content", in which to activate the function you need to check the box "Use JavaScript".

To disable the feature, uncheck this box.

To save the changes, click the "OK" button and refresh the browser page.

You do not need to restart your browser for the changes to take effect. After activation, you will be able to fully browse the web and perform actions on interactive services.

Opera Versions 10.5 to 14

First of all, we need to open the browser settings.

In the upper left corner, press the button "Menu", in the context menu, hover over the item "Settings" and click on the sub-item "General settings ...".

This will open a new browser settings window.

In it, you must select the tab "Advanced".

In the left menu of the tab, click on the item "Content", after which we activate the function by checking two checkboxes on the items "Enable JavaScript" and "Enable Java".

To deactivate these checkboxes must be unchecked.

Activating and deactivating javascript in Opera version 10.5 to 14

After you have checked or unchecked the boxes, save the changes by pressing the OK button.

Now restart the browser for the changes to take effect. All javascript functions will become available to you.

Versions 15 and up

In these versions of the Opera browser, activating JavaScript is much easier.

In order to open the settings window, you need to press the hot key combination Alt + P in an open browser. In the menu that opens, open the tab "Sites".

To activate the function, you need to set the "checkbox" on the item "Allow JavaScript execution", to deactivate - "Prohibit JavaScript execution".

After that, just click the "OK" button to save the changes and refresh the page you are viewing with the F5 key or by clicking the corresponding icon on the left of the address bar.

You don't need to restart your browser.

safari

To enable the JavaScript function in Apple's proprietary browser, you need to go to the settings.

To open them, you need to click the "Safari" button and select " Settings».

If you notice an error, select a piece of text and press Ctrl + Enter
SHARE:
Computers and modern gadgets