Style properties in JavaScript Inline code with window and Date object Passing query to Google Creating Functions Creating Array Selection Statement if…else
Style properties in JavaScript style.backgroundImage style.backgroundColor style.border style.margin style.padding style.filter style.visibility style.position style.top style.left style.color style.fontSize style.fontWeight style.width
Inline code with window and Date object Inline code found between <script> and </script> tag. Inline code is invoked or executed when the browser gets up to the line of code <body> <script type=“text/javascript”> <!-- var name= window.prompt(“question”, “initial value”); var d = new Date(); var day= d.getDate(); //--> </script> </body>
Passing query to Google Step 1: Create a text field. Assign a name to the field Step 2: Create a button. Using an event handler, send the text value to google.
Creating Functions Function contains a set of statements performing a single task Major advantage of having function is programmer’s ability to reuse Syntax: function with no parameter function funName() { } function with parameter function funName( para1, para2, etc) { }
Calling Functions A function has to be called in order to be executed. This can be done through event handler or inline technique Syntax //calling function with no parameter funName() // calling function with parameter funName(argument1, argument2, etc)
Creating Array Array object stores a list of values Each value is an element of the Array and has an associated index Create array with initial values var arrayName = new Array(elment0, element1, element2, etc); Create array with size defined var arrayName = new Array(3); arrayName[0] = value; arrayName[1] = value; arrayName[2] = value;
Selection Statement Selection or conditional statements perform different actions based on different conditions If Statement Syntax if( condition ) Statement Semantics Evaluate the condition (true or false) If the condition is true True: DO STATEMENT False: SKIP the STATEMENT
Selection Statments Syntax: if…else if(condition) { if the condition is true, the code in here is executed} else { if the code is false, the code in here is executed}