1. JavaScript :
JavaScript 是一种轻量级的编程语言(“脚本语言”),用于使网页具有交互性。它可以将动态文本插入到 HTML 中。 JavaScript 也被称为浏览器语言。 JavaScript(JS) 与Java不相似或相关。这两种语言都有类似 C 的语法,广泛用于客户端和服务器端 Web 应用程序,但只有很少的相似之处。
2.Java:
Java是一种面向对象的编程语言,具有虚拟机平台,允许您创建几乎在所有平台上运行的编译程序。 Java承诺“一次编写,随处运行”。
Java和 JavaScript 的区别:
Java | JavaScript |
---|---|
Java is strongly typed language and variable must be declare first to use in program.In Java the type of a variable is checked at compile-time. | JavaScript is weakly typed language and have more relaxed syntax and rules. |
Java is an object oriented programming language. | JavaScript is an object based scripting language. |
Java applications can run in any virtual machine(JVM) or browser. | JavaScript code used to run only in browser, but now it can run on server via Node.js. |
Objects of Java are class based even we can’t make any program in java without creating a class. | JavaScript Objects are prototype based. |
Java program has file extension “.Java” and translates source code into bytecodes which is executed by JVM(Java Virtual Machine). | JavaScript file has file extension “.js” and it is interpreted but not compiled,every browser has the Javascript interpreter to execute JS code. |
Java is a Standalone language. | contained within a web page and integrates with its HTML content. |
Java program uses more memory. | JavaScript requires less memory therefore it is used in web pages. |
Java has a thread based approach to concurrency. | Javascript has event based approach to concurrency. |
Java supports multithreading. | Javascript doesn’t support multi-threading. |