Java script what is it for. What is Javascript for and what does it do? Examples. Alternative programming languages

The JavaScript programming language is an object-oriented scripting language originally developed by Netscape Communications under the name LiveScript, but later renamed "JavaScript" and with a syntax closer to Sun Microsystems' Java. JavaScript was later standardized by ECMA under the name ECMAScript. Microsoft calls its versions JScript.

The change in name from LiveScript to JavaScript occurred around the same time that Netscape included support for Java technology in the Netscape Navigator browser. This change has created a lot of confusion in the minds of those learning to program for beginners. There is no real connection between Java and JavaScript; their similarities begin and end with similar syntax and the fact that both languages ​​are widely used on the Internet.

JavaScript is an object-oriented scripting language that interacts through an interface called the Document Object Model (DOM) with content that can be executed on the server side (web servers) and on the client side in the user's web browser when viewing web pages. Many websites use client-side JavaScript technologies to create powerful dynamic web applications in programming for dummies. It can use Unicode and can use power and strength regular expressions(this was introduced in version 1.2 of Netscape Navigator 4 and Internet Explorer 4). JavaScript expressions contained as a string can be executed using the EVAL function.

One of the main challenges for JavaScript is small functions embedded in HTML pages and allowing you to interact with the DOM from the browser to execute certain tasks, which is not possible in static HTML: such as opening a new window, validating values ​​entered into a form, changing the image when hovering the mouse cursor, etc. Unfortunately, writing such functions is quite tedious because browsers are not standardized, different browsers may create different objects or scripting methods, and therefore you often have to write different versions JavaScript functions for various browsers, but this is not very convenient when learning the basics of programming.

JavaScript / ECMAScript is supported by such engines as:

  • Rhino
  • SpiderMonkey

Environment

The markup comment is required to ensure that the code does not display as text in browsers that do not recognize the . tags in XHTM/XML documents, however, will not work if commented out. Modern browsers that support XHTML and XML are well designed enough to recognize , so the code in these documents remains uncommented.

An HTML element can generate internal events to which a script handler can be connected. To create the right HTML document 4.01, you need to insert an appropriate default script link statement in the document header section.

Elements of language

Variables

Variables are usually dynamically typed. Variables are defined either by simply assigning a value to them or by using the "var" operator. Variables declared outside a function are in "global" scope, visible throughout the web page; variables declared inside a function are local to that function. To pass variables from one page to another, the developer can set a "cookie" or use a hidden frame or window in background for their storage.

Data structures

The main type is an associative array data structure similar to hashes in the Perl programming language or Python, Postscript and Smalltalk dictionaries.

Elements can be accessed by numbers or associated names (if these have been defined). Thus, the following expressions may all be equivalent:

MyArray,
myArray.north,
myArray["north"].

Declaring Arrays

MyArray = new Array(365);

Arrays are implemented so that only certain (non-empty) elements will use memory, they "discharge the arrays". If we set the set myArray = "something there" and myArray = "something else there", then we have used space only for these two elements.

Objects

JavaScript has several kinds of built-in objects, namely Object, Array, String, Number, Boolean, Function, Date and Math. Other objects belong to DOM objects (windows, forms, links, etc.).

By defining constructor functions, you can define objects. JavaScript is a prototype-based object-oriented language. You can add additional properties and methods to individual objects after they have been created. To do this, you can use a prototype statement for all instances of a particular type of object.

Example: Creating an Object
// Constructor function

Function MyObject(attributeA, attributeB) ( this.attributeA = attributeA this.attributeB = attributeB )
// Create an object
obj = new MyObject("red", 1000)

// Access an object attribute
alert(obj.attributeA)

// Access attribute with associative array designation
alert(obj["attributeA"])

The hierarchy of objects can be reproduced in JavaScript. For example:

Function Base() ( this.Override = _Override; this.BaseFunction = _BaseFunction; function _Override() ( alert("Base::Override()"); ) function _BaseFunction() ( alert("Base::BaseFunction()" ); ) ) function Derive() ( this.Override = _Override; function _Override() ( alert("Derive::Override()"); ) ) Derive.prototype = new Base(); d = new Derive(); d.Override(); d.BaseFunction();

As a result, we get on the screen: Derive::Override() Base::BaseFunction()

Control instructions
If ... else if (condition) ( statements )
Cycles
while (condition) ( statements ) Do ... while do ( statements ) while (condition); For loop for (; ; ) ( statements ) For loop ... in
This loop goes through all the properties of an object (or element in an array)
for (variable in object) ( statement )

Selection operator
switch (expression) ( case label1: statements; break; case label2: statements; break; default: statements; )

Functions
The body of the function is contained in (the body can be empty), and the list of arguments is indicated inside () following the function name. Functions can return a value after execution.

Function(arg1, arg2, arg3) ( statements; return expression; )

As an example, let's look at a function based on the Euclidean greatest common divisor algorithm:

Function gcd(a, b) ( while (a != b) ( if (a > b) ( a = a - b; ) else ( b = b - a; ) ) return a; )

The number of arguments when calling a given function does not necessarily have to provide as many arguments as were specified when the function was declared. In a function, arguments can also be accessed through an argument array.

Each function is an instance of a function, a base type of object. Functions can be created and assigned like any other objects:

Var myFunc1 = new Function("alert("Hello")"); var myFunc2 = myFunc1; myFunc2();

Result on screen:

User interaction

Most user interaction is done using HTML forms, which can be accessed through the HTML DOM. However, there are also some very simple remedies communication with the user:

Alert dialog box
Confirm dialog box
Dialog lines
Status bar
Consoles

Text elements can be the source of various events, which can trigger actions if an EMCAScript event handler is registered. In HTML, these event handler functions are often defined as anonymous functions directly in the HTML tags.

JavaScript® (often shortened to JS) is an interpreted programming language designed for interacting with web pages. JavaScript runs on the client side of the Internet 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 the website developer to control how the 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 forms appearance 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 loads, they are immediately executed. The process of executing a script is called "interpretation".

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

Today, every browser supports JavaScript, 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, interacting with the server:

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

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

JavaScript vs ECMAScript

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

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

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

Formally, when developers refer to ECMAScript, they are usually referring to 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 will be used. The textbook will also use the common abbreviation ES5 when referring to the fifth release 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 in common with the Java language other than its 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. There is a special opportunity for Internet pages - 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. This binary files, and if you open them, you won't see source applet.

JavaScript scripts reside 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. A 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 easy language programming that has simple syntax, specialized built-in functionality and minimum requirements to create objects. You don't 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 function return types of JS scripts are not explicitly typed.

What do you need to learn JavaScript?

No prior knowledge of JavaScript is required, but since JavaScript lives inside web pages and controls their dynamics, it is assumed that you are familiar with the basics HTML language, although the possibility of “parallel” JavaScript is not excluded.

Majority JavaScript scripts are designed to “revive” HTML, i.e. the purpose of creating a script is to demonstrate how the appearance of the page will change when changing the values ​​of the HTML tag parameters. Collected and properly formatted, these types of scenarios are an example of a developed web application.

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

When learning JavaScript, it's important to run the examples presented in each lesson, modify them, and run them again to see how well you understand the material you've learned. This requires a JavaScript interpreter. Luckily, 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 in HTML files, in tags, and when the HTML file is loaded, the code will be executed by the browser. It's worth noting that you don't need 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 your browser's built-in Web Console tool.

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

The panel includes many tabs that allow you to explore HTML document structure, CSS styles, etc. 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 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 managed to get used to it, then there is nothing stopping you from continuing to use it.

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

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

This is a regular HTML document

We exit back to HTML

Please note: In simple JavaScript experiments like this, you can omit the , tags in the HTML file as well.

Learning JavaScript, like other programming languages, is not an easy task, but it is definitely worth the effort and time. 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 acquired without effort is like ripples on the water - very soon not a trace will remain of it.

E-books, free online courses and online platforms for problem-based learning, the choice of sources of quality knowledge today is almost limitless. But how to motivate yourself to self-study How to learn to study independently?

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 daily routine so that you can devote at least one hour every day to learning JavaScript. Don't try to learn everything at once in a short period of time. Breaking the self-education process into small study sessions creates a feeling of quick success and motivates you to return to learning the 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. Practice according to the 25/5 principle. Try 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.

Use recollection practices - the basis of learning. The more often we recall information, the longer it will be stored in our memory.

An effective recall technique is delayed recall: on a card, on one side, write a question that relates to the material you studied, and on the other, 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 put aside for a week until the next repetition. If you make a mistake, you need to repeat the question the next day. The longer your 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, you just need to write a lot and analyze examples. good code. When working through the examples, carefully go through all the lines of code - you must make sure that you understand how each line works. Don't be afraid to experiment. Learn to display some data in a browser window and analyze it. For example, what is displayed on the screen and after what, did you get what you wanted, and if not, then why.

Whatever learning method you choose, do not forget that it should be interesting for you and reinforced 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.

Programming is not just a way to earn big money and is not even entirely mental work. This is an opportunity to understand what the world around us consists of, decompose it into small particles, and then reassemble it, guided by our own logic and knowledge.

Programming languages ​​are just a tool with which a person builds rules in created systems.

The Internet presents a wealth of opportunities that bright and enterprising minds are seizing upon. Of course, web development also has its own tools for bringing ideas to life. One of them is the JavaScript programming language, which will be discussed in this article:

general information

Many people, even those who have nothing to do with the IT field, have heard the word Java. A revolutionary platform-independent language in which applications are actively written for mobile systems. It was developed by the promising company Sun, which then came under the wing of Oracle. But neither company has anything to do with JavaScript:

All that was required from Sun was permission to use part of the name. Surprisingly, JavaScript is not owned by any company at all.

When writing web applications, JavaScript programming is used most often. To briefly list key features of this language, the following should be highlighted:

  • Object orientation. Program execution represents the interaction of objects;
  • Data type conversion is carried out automatically;
  • Functions are objects of the base class. This feature makes JavaScript similar to many functional programming languages ​​such as Lisp and Haskell;
  • Automatic memory clearing. So-called garbage collection makes JavaScript similar to C# or Java.

If we talk about the essence of using JavaScript, then this language allows you to “revive” motionless website pages using code that can be launched for execution (so-called scripts). That is, we can draw an analogy with cartoons, where html and css are the drawn characters, and JavaScript is what makes them move.

If we talk about JavaScript syntax, then it has the following features:

  • Register is important. Functions called func() and Func() are completely different;
  • Operators must be followed by a semicolon;
  • Built-in objects and operations;
  • Spaces are not counted. You can use as many indentations as you like, as well as line breaks, to format your code.

The simplest JavaScript code looks like this:

Scope of application

In order to understand why JavaScript is needed and how necessary it is to learn it, we should highlight some areas in which it is used given language programming.

  • Web application development. Do you want to install a simple counter, organize data transfer between forms, or place a game on your website? Then JavaScript will be a faithful assistant in this matter;
  • "Active participation" in AJAX. This technology has made it possible to significantly speed up the operation of applications by exchanging data with the server in the “background” mode:
  • OS. Some people may not have known, but Windows, Linux and Mac have their own browser competitors, the lion's share of which is written in JavaScript;
  • Mobile applications;
  • Field of study. Any programming specialty at a university includes the study of JavaScript to one extent or another. This is due to the fact that the language was originally developed for not very strong programmers. JavaScript lessons are logically woven into basic course HTML, so mastering it is quite simple.
Advantages and disadvantages

Don’t think that JavaScript is some kind of panacea for all problems, and every programmer uses this language with a smile on his face. Everything in the world has its positive and negative sides. First, let's note the shortcomings.

  • The need to provide cross-browser compatibility. Since JavaScript acts as an Internet technology, you have to put up with the rules that it sets The World Wide Web. The code must run correctly in all, or at least the most popular, browsers;
  • The inheritance system in a language makes it difficult to understand what is happening. JavaScript implements prototype-based inheritance. People who have studied other object-oriented programming languages ​​are accustomed to the usual “child class inherits parent class.” But in JavaScript, such things are handled directly by objects, and this is beyond your comprehension;
  • Absent standard library. JavaScript doesn't provide any capabilities for working with files, I/O streams, or other useful things;
  • The syntax in general makes it difficult to understand. The beauty of the code is clearly not the strong point of JavaScript, but the main rule of programmers is observed: “Does it work? Don't touch! "
Now it is worth noting some advantages
  • JavaScript provides a large number of capabilities for solving a wide variety of problems. The flexibility of the language allows the use of many programming patterns in relation to specific conditions. The inventive mind will have a real pleasure;
  • The popularity of JavaScript opens up a considerable number of ready-made libraries for the programmer, which can significantly simplify the writing of code and level out syntax imperfections;
  • Application in many areas. The wide capabilities of JavaScript give programmers a chance to try themselves as a developer of a wide variety of applications, and this, of course, fuels interest in professional activities.

You shouldn’t pay attention to the fact that there were more minuses than pluses. JavaScript is firmly entrenched in its niche, and there is no criticism of it from there this moment won't knock it out.

For those who want to study

A difficult and long path lies ahead for those who decide to thoroughly study JavaScript. For beginners, there are basic recommendations, following which you can significantly simplify your learning.

  • First of all, HTML. You can't start doing anything for the Internet without the basics. Cascading Style Sheets (CSS) will also come in very handy;
  • Use new literature. Programming is not physics, the laws of which are inviolable, but new ones teaching aids- these are stripped down old ones. IT technologies are constantly evolving, and useful updates should not be neglected;
  • Try to write all sections of the program yourself. If something doesn’t work out at all, you can borrow someone else’s code, but only after first understanding each line for yourself;
  • Debugging is your best friend. Finding errors quickly is one of the the most important moments in programming;
  • Don't ignore formatting rules. Of course, the code will not become better or worse due to different numbers of indentations and spaces, but ease of reading and understanding by the programmer is also an important point. The code below? very difficult to perceive, especially if you are not him
  • Variable names must have lexical meaning. In the process of writing simple programs This doesn’t seem important at all, but when the number of lines of code exceeds a thousand, all the devils break their legs;

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

A little 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 was significantly influenced by its predecessor - ECMAScript.

The overall purpose of its creation was to make it easy to use by non-specialists and easy to operate. JavaScript is now one of the most popular programming languages ​​of its kind. What makes it easier to use is that it is built into applications. JavaScript is an object-oriented language, but its functionality differs quite a bit from what similar types of languages ​​typically provide.

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

It implements work with objects and classes differently, can automatically determine types, and supports anonymous functions. JavaScript Syntax stands between Java and C, but in functionality it is more closely related to other programming languages. There are many functionality differences between Java and JavaSkript. For example, Java implements the object approach on classes, while JavaScript implements it on prototypes. The code can be embedded into a web page in certain 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) — path to the file.

JavaScript is considered quite secure 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. He can't even open too big program window. The main vulnerability of JavaScript is cross-site scripting.

The script is embedded in the page on which the user was working and thus can take over his account. This may result in unwanted behavior. This can also happen due to errors in the browser itself. When developing and working with scripts, you should always take into account that the code or the program itself may fall into the hands of attackers. They can be altered or mixed up in various ways to produce a spyware or malicious effect.

You should not enter any confidential data into the same script forms. All of them can be sent to a third-party server, bypassing their real purpose and thus be stolen. Browsers can also run JavaScript outside of a special mode, which can lead to errors and scripts gaining too much power. This is one of the difficulties in using them. Scripts that are often launched as normal applications can be Trojan programs.

According to Github statistics, at the moment, Java and JavaScript are the most popular programming languages, after Python, PHP and Ruby. Despite the similarity in their names, these are very different languages. You might think that JavaScript is a simpler, lighter version of Java. But you are wrong. These are two completely different full-fledged programming languages ​​that allow you to do different things, but at the same time they have more differences than similarities.

In this article we will look at the difference between java and javascript to help you choose the language that is best suited to solve your problems. As you will see, both languages ​​are very rarely used to perform the same tasks.

The first version of Java, codenamed "Oak" and "Green" after initial development, was released in May 1995. Many programmers at the time regarded this language as a replacement for C/C++ because it had similar syntax and also introduced new concepts. The language made programming easier and safer.

One of the core principles of Java, which began then and continues today, is the idea that programmers can write code once and use it everywhere. Unlike compiled executable files, which have different formats for different platforms, java code is compiled into a single JAR file that can be run in any Java-supporting environment.

This is made possible by the Java Machine (JVM). A Java machine is a regular program that acts as an intermediary between operating system and Jar file. It reads a program file that contains Java instructions and turns them into instructions for the platform on which it runs at runtime. This process is called Just-in-time compilation or JIT.

What is JavaScript?

JavaScript emerged as a simple language for creating constraint HTML forms. When Netscape Communications decided they wanted a more dynamic Internet, they created a new language that could be used right inside HTML. This language was called LiveScript and was developed in ten days.

The language then developed for some time under this name, but then several reasons appeared to change the name. Firstly, JavaScript and Java were supposed to complement each other, so JavaScript received a similar syntax, and secondly, at that time Java was very popular, and therefore the developers, in order to attract more people to the language, decided to use a well-known word in the name and replaced Live in Java. This is how JavaScript was born. But only the syntax is similar in languages; later, Java was used less and less on the Internet and the languages ​​diverged their paths. Nowadays HTML, CSS and JavaScript are the main components of web development.

Unlike Java, which is compiled, JavaScript is a completely interpreted language. When you visit a site that uses JavaScript, your browser receives the full source code for the program. Then it is executed on the fly using the JavaScript engine. Various browsers They use different engines: V8 (Chrome), SpiderMonkey (Firefox), Chakra (Edge) and so on.

Similar aspects of Java or JavaScript

Despite all the differences, these languages ​​have several similarities that can be considered even if you do not intend to use both languages ​​for web development. Here are the main ones:

  • Objective-Oriented Programming (OOP) - Both languages ​​require the programmer to use the principles of objects and the relationships between them while coding. Both languages ​​support OOP patterns such as interfaces, encapsulation, and polymorphism.
  • Forend Development - Both languages ​​can be used to develop a forend, in other words, a user interface that works in conjunction with the server. JavaScript can be embedded in HTML, or as a third-party library on site pages. And Java can run in the browser as a java applet.
  • Backend development - in other words - server software development. Java has long been used in backend technologies by Apache, JBoss, and WebSphere projects. New technology,Node.js allows you to run servers written in JavaScript.
Main differences between Java vs JavaScript

Initially, languages ​​were developed to solve completely different problems. Java is intended more for creating full-fledged applications, while JavaScript is a scripting language for organizing an interface on the web. Here are the main differences to make it easier to understand the difference between java and javascript:

  • Compilability and interpretation - as I wrote above, Java is a compiled programming language, and JavaScript is interpreted. The only difference is in the implementation; in fact, both languages ​​can run on different platforms.
  • Static and Dynamic Type Checking - Java uses static type checking. The variable's type is checked at compile time. The programmer must explicitly specify what type the variable will be - string, number, floating point number, and so on). JavaScript, like other scripting languages, uses dynamic typing. The correct use of types is checked at run time. The programmer does not need to specify the type of the variable when declaring it. Both approaches have many advantages and disadvantages. The most important difference between java and javascript is that with static typing, most errors appear at the development stage, because the compiler knows what to expect, the code runs faster and consumes less memory. The advantage of dynamic typing is that programs are written faster and easier.
  • Concurrency - the implementation of the ability to execute multiple sequences of instructions at the same time is very different in Java and JavaScript. Java allows you to use multiple threads to run parallel tasks. Implementing concurrency in JavaScript is very complex. It is only available in Node.js. On the main thread, this is implemented through a run queue called an event loop. Both methods work well, but Java threads are faster.
  • Classes and Objects - Java uses classes and relationships between them. The properties of an object are defined in a class and are an immutable part of the class. You can inherit classes from other classes and then they receive all the properties of their parents. You might be surprised, but there are no classes in JavaScript. There are only objects there. And inheritance is implemented differently. All objects can be inherited from other objects directly. To do this, just specify the desired object as a prototype.
When is it best to use?

As with all languages, your choice of Java vs JavaScript will depend on many factors. For example, on what you want to create and what resources you have for it. JavaScript is better suited for web technologies, while Java is ideal for creating regular programs and anything else.

It is better to choose Java if you are developing:

  • Android application;
  • Commercial software;
  • Scientific computing software;
  • Big Data analysis software;
  • BY general purpose or security tools;
  • Server programs.

It is better to use JavaScript in the following areas:

  • Dynamic Single Page Applications (SPA);
  • Fort-end applications (Query, AngularJS, Backbone.js, Ember.js, ReactJS);
  • Server applications (Node.js, MongoDB, Express.js and so on);
  • Mobile applications (PhoneGap, Ract Native, etc.).
conclusions

In this article we looked at how java differs from javascript. As you can see, there are simply a lot of differences, despite the fact that the languages ​​have a similar name. The question of which is better than java or javascript is difficult to answer, because the languages ​​have very different areas of application. I hope this information was useful to you.

To conclude, a video joke about the confrontation between Java and JavaScript based on Game of Thrones: