JavaScript and Java

A

Andrew Thompson

Gregc. said:
Is the syntax for JavaScript the same for Java?

No, they are different languages. (Though some of the
code and method names can look similar).

(moments later..)
Actually, now that I check the definition of 'syntax',
I'll need to ease back from the first answer.

The syntax of Java and JavaScript has a lot of
similarities, but probably no more than the similarities
common to any two randonly chosen, high level,
OO languages.

Andrew T.
 
A

Alex Hunsley

Gregc. said:
> Hi
>
> Is the syntax for JavaScript the same for Java?
>
> Greg

There's this site called "Google"....
Searching for "java versus javascript" is probably a good idea.
 
G

Gregc.

Alex said:
There's this site called "Google"....
Searching for "java versus javascript" is probably a good idea.

Yes, I use a thing called "Google" regularly
 
G

Gregc.

Andrew said:
No, they are different languages. (Though some of the
code and method names can look similar).

(moments later..)
Actually, now that I check the definition of 'syntax',
I'll need to ease back from the first answer.

The syntax of Java and JavaScript has a lot of
similarities, but probably no more than the similarities
common to any two randonly chosen, high level,
OO languages.
Thankyou.
 
L

Lasse Reichstein Nielsen

Gregc. said:
Is the syntax for JavaScript the same for Java?

No.
They have a lot of similarities, probably because they both
took the basic syntax from the C language (or from another
language that took it from C).

Java and JavaScript has less in common that Java and C++
(or Java and C#, or C# and C++, or ...), mainly because
JavaScript is not a class based language like the other.

For the basic flow control statements (if, for, while, do),
which have nothing to do with being class-based or not,
the languages are much closer. If you can read one, you can
probably read another.

/L
 
J

John W. Kennedy

Lasse said:
No.
They have a lot of similarities, probably because they both
took the basic syntax from the C language (or from another
language that took it from C).

There are some aspects of JavaScript that were taken from Java, such as
putting the standard mathematical functions into a name space called
Math (though in the case of Java, the name space is in the form of a
class, and in the case of JavaScript, it is in the form of an object).
 
T

tri

Hi
Greg

Most of the syntax for JavaScript is same as Java. There are many
differences
Like:-
In JavaScript we compare two strings for equality with ==
whereas,
In Java we compare two strings with equals() function.

:)
Trilochan Singh.
 
O

Oliver Wong

Gregc. said:
Is the syntax for JavaScript the same for Java?

They are different. One example of a difference: "class" is a reserved
word in Java, but not in JavaScript.

- Oliver
 
O

Oliver Wong

Oliver Wong said:
They are different. One example of a difference: "class" is a reserved
word in Java, but not in JavaScript.

Moments after posting this, I find out that "class" is a "future
reserved word" in JavaScript, for the purpose of possible extensions. So
I'll rephrase the difference as:

"public class Foo {}" (without the quotes) is a legal Java compilation unit,
but not a legal JavaScript compilation unit.

- Oliver
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
474,266
Messages
2,571,081
Members
48,772
Latest member
Backspace Studios

Latest Threads

Top