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


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: 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.

4. Java
Java and JavaScript have a superficially similar syntax that is loosely based on C++.

5. Failed expectations
Java was supposed to rule the Internet.

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