Sunday, October 19, 2014

Lesson 5: Introduction to JavaScript



Hello everyone

This week we will be discussing introduction to JavaScript.
JavaScript is a a script language. A script language is a programming designed to enable computer users to write useful programs easily. Scripting languages include JavaScript, perl, PHP(PHP Hypertext preprocessor), TCl Tool Command Language) ColdFusion, VBScript and REXX. In this discussing we will focus on only JavaScript.
JavaScript is a scripting language that adds dynamic interactivity to web pages. JavaScript is considered a scripting language because it supports scripts, which are programs that interpret and automate task execution.
Javascript characteristics:
JavaScript is object based: This means that functions come from objects
JavaScript is event-driven: Scripts are driven by events(cursor clicking)
JavaScript is a platform-independent: Works in most browsers, but may render differently.
JavaScript enables quick development: Because JavaScript does not require time-consuming compilation, scripts can be developed quickly.
JavaScript is relatively easy to learn: JavaScript does not have all of the complex rules associated with Java or other full object-oriented languages. 
                                JavaScript vs. Other Languages
JavaScript has similarities to some other scripting languages. Today we will clarify the relationships between JavaScript and some other languages to which it is often compared.
JScript: Microsoft version of JavaScript. JavaScript and JScript have several difference. If you mistakenly use one instead of the other, there might be some  compatibility problems. 
VBScript: Both VBScript and JavaScript extend the capabilities of static Web pages.

Java: Advanced programming language. It is generally used to create stand-alone applications and a special type of mini-application called a Java applet. JavaScript has no relation to Java.
                        Objects, Properties, methods, and Variables
objects: parts of JavaScript. Each object has three groups of attributes. These attributes are
 properties,values, and methods 
Properties: various attributes of an object, such as height, color, font size, sentence length and so forth.
Values: the specific qualities of properties. E.g. the statement color="yellow" assigns a value to a property.
 Methods:the actions that an object can be made to perform, such as a calculation, an onscreen move or the writing of text into a window. Methods often describe the actions that an object performs with its properties. Here are some commonly used methods
alert(): creates a pop-up box with the specified message string, which the user can dismiss by clicking a button in the box.
 prompt(): creates a pop-up box with the specified message string and requests user input into a text field in the box.
 confirm(): creates a pop-up box with the specified message string and requests user confirmation (yes or no) by clicking the OK or Cancel button in the box.
document.write(): writes the specified message string in the page.
Variables: A named space of memory that holds a value. The value can change depending on a condition or information passed to the program, or by reassignment of a new value.
Naming variables: The first character of the variable must be a letter, the underscore ( _ ) character or the dollar sign ( $ ). No other initial characters are allowed. Subsequent characters can be letters, numbers and/or underscore characters.
Variables can hold numbers: numerical values, strings: text message, boolean: true or false, object: an object, null: hasn't been defined yet.
                             Expressions and Operators 
expression: Part of a statement this is evaluated as a value; it can use any combination of variables, operators, and other expressions.
operator: A symbol character used in programming expressions to instruct the program how to store or manipulate (operate on) a value.
operand: Data that is to be operated upon or manipulated in some manner.
                      JavaScript If /Else Statements
Conditional statements are used to perform different actions based on different conditions.
 The if() condition helps  you check conditions, while for() allows you to go through a set of data and do the same with each piece of data.
Last but not the least, to code JavaScript into web documents the code is placed between <script> tags( in either head or body)
You can also put JavaScript into web documents through inline scripting. Inline scripting is attributed to a specific element. I hope you learned something about JavaScript


Sources:
http://www.quirksmode.org/js/state.html  
http://www.w3schools.com/js/js_if_else.asp
http://education.certification-partners.com/CIW/

No comments:

Post a Comment