Send
Close Add comments:
(status displays here)
Got it! This site uses cookies. You consent to this by clicking on "Got it!" or by continuing to use this website. nbsp; Note: This appears on each machine/browser from which this site is accessed.
The JavaScript programming language
c
go
java
js
lua
py
vbs
rkt
scm
pro
1. The JavaScript programming language
Here is some background on JavaScript.
2. JavaScript
JavaScript is a scripting language that is typically embedded in HTML web pages to provide client-side processing at the web browser. JavaScript is:
a textual language that is interpreted, not compiled.
similar in spirit to Visual Basic but with functional capabilities
embedded as text in an HTML page.
used to extend the functionality of HTML pages on the client side.
JavaScript is also a server-side or command line language, as used in node.js.
3. Names for JavaScript
There are many names for JavaScript.
ECMAScript is the formal name form the ECMA (European Computer Manufacturers Association ) .
LiveWire was Netscape's original name for JavaScript.
Microsoft's version of JavaScript was JScript
4. Java
Java and JavaScript have a superficially similar syntax that is loosely based on C++.
Java is a very nice object-oriented programming language that started as a failed toaster language (i.e., intended for embedded systems).
Sun Microsystems used Java to take advantage of the popularity of the web.
Netscape asked Sun if they could call their scripting language JavaScript.
5. Failed expectations
Java was supposed to rule the Internet.
Java was a failed toaster (embedded systems) language.
Java was a failed Internet language (JavaScript won the battle).
Java is used in enterprise (entire organization) computing (as a platform independent language).
Java is used in Android development (though Google would like this changed).
6. JavaScript
JavaScript was developed in a few weeks and rushed to market - good and bad parts.
JavaScript had a lot of ML functional language concepts in it - which helped it adapt and win the Internet battle with Java.
JavaScript is often used as a scripting language in other applications, much like Lua and VBScript.
7. JSON
The
JSON (
JavaScript Object Notation ) is a common data exchange format, based on the data format of JavaScript.
Oracle, which bought out Sun Microsystems, has the trademark for the JavaScript name.
8. node.js
Node.js is a server-side JavaScript system that can also be used for command line application scripting purposes.
What follows are some node.js JavaScript program examples.
9. Hello world in JavaScript
The file type of a
JavaScript program file is
js .
The following Linux command(s) create/edit a hello program in the your home directory using the nano text editor.
nano ~/hello.js
Create the following program text in the editor that will output the text "Hello world"
console.log("Hello world");
To exit with save, remember to press
Ctrl-X , then "
y " (for yes) and
Enter to exit.
The following Linux command(s) run the program.
node ~/hello.js
The output should be as follows.
Hello world
10. Program: decimal to binary
Let us look at a program to implement to algorithm for decimal to binary conversion.
The routine toBinary1 takes as input a value and returns the string representation in binary (base 2 )
The first part of the program will use the hard-coded value of 156 .
The second part will use a loop to output the decimal values and binary representations of the values from 0 to 16 .
11. JavaScript code
Here is the JavaScript code.
12. JavaScript output
Here is the output of the JavaScript code.
13. End of page
14. Acronyms and/or initialisms for this page
2 acronyms omitted (login required)