Question
What is the difference between JavaScript and Java?
Answer
JavaScript and Java are completely different languages that share a similar name for marketing reasons.
| Feature | JavaScript | Java | |---|---|---| | Type | Scripting language | Object-oriented language | | Typing | Dynamic (loosely typed) | Static (strongly typed) | | Compilation | Interpreted | Compiled to bytecode | | Platform | Browser / Node.js | JVM | | Concurrency | Single-threaded + event loop | Multi-threaded | | Syntax | Flexible, prototype-based OOP | Strict, class-based OOP |
// JavaScript – no type declaration needed
let name = "Alice";
let age = 30;
// Java – types must be declared
String name = "Alice";
int age = 30;