JavaScript is a programming language well known for scripting web pages, although it might be used in other environments such as Node.js, Apache CouchDB and Adobe Acrobat. The main use of programming languages in web pages is adding functionality to the page i.e. make it more dynamic and interactive.
Converting a web page from HTML static page to a dynamic page means that clicking, scrolling, and clicking a button will have certain functions to do. your web page can ask for data and reply with info, will have pop up windows, will do arithmatic and logic operations, and a lot more.
As we mentioned earlier, JavaScript prepared web page can interact with user, now we will mention some of syntaxes used for this purpose (simplified as possible):
Syntax | Semantics |
---|---|
document.write(sth) | prints sth on web page |
prompt | asks for data entry |
alert(message) | shows a messaage to users |
JavaScript can process data using a set of statements and operations. Statements like:
operations like:
+
for summation*
for multiplication/
for division<>, ==, >=, <=, !=
for comparison
Variables are containers to store data in order to make processes on, or to be recalled later, data can be a number, a string (text), a boolean (having a value of yes or no),….etc. Each variable has a name, a value, and data type
To assign a value for a variable use = sign, for example: var name = “Ahmad” stores the text Ahmad in a variable called name.
For details, please visit: