Home  >  Article  >  Java  >  What are the differences between javascript and java

What are the differences between javascript and java

WBOY
WBOYforward
2023-04-20 09:19:126975browse

The differences between javascript and java are as follows

1. Different compilation methods

Java programs are compiled and executed; JavaScript is interpreted and executed by the browser;

2. Different language types

Java is an object-oriented programming language. No matter whether the program developed is simple or not, objects must be designed; JavaScript is an object-based scripting language that provides a wealth of built-in Objects are for direct use by developers.

3. Different ways of declaring variables

Java is a strongly typed language, variables must be declared before use and the type of the variable must be declared; JavaScript is a weakly typed language, and there is no need to declare variables when declaring them. You need to declare the type of the variable, or even use the variable directly without declaring it.

4. Different code formats

Java code must be compiled into a bytecode file using the corresponding compilation tool. When embedded in an HTML document, the tag must be passed To embed bytecode files; while JavaScript code is a text character format, HTML documents can be embedded using the <script></script> tag, which can directly embed JavaScript code or embed JavaScript script files.

What are the characteristics of JavaScript

1. js is an interpreted scripting language;

2. With the support of most browsers, js can be used in a variety of It runs under the platform and has cross-platform features;

3. JS is a weakly typed scripting language, which does not have strict requirements on the data types used, and can perform type conversion, making it simple and easy to use;

4. The js language has high security and can only achieve information browsing or dynamic interaction through the browser, thereby effectively preventing data loss;

5. An object-based scripting language, js can not only Create objects or use existing objects.

The above is the detailed content of What are the differences between javascript and java. For more information, please follow other related articles on the PHP Chinese website!

Statement:
This article is reproduced at:yisu.com. If there is any infringement, please contact admin@php.cn delete