JavaScript Introduction JavaScript is the most popular scripting language on the internet, and works in all major browsers, such as Internet Explorer,

Slides:



Advertisements
Similar presentations
1 What is JavaScript? JavaScript was designed to add interactivity to HTML pages JavaScript is a scripting language A scripting language is a lightweight.
Advertisements

Introducing JavaScript
Javascript Introduction Norman White Material is from w3schools.com Go there to run examples interactively.
The Web Warrior Guide to Web Design Technologies
HTML Forms JavaScript Introduction / Overview Lab Homework #1 CS 183 4/8/2010.
1 Outline 13.1Introduction 13.2A Simple Program: Printing a Line of Text in a Web Page 13.3Another JavaScript Program: Adding Integers 13.4Memory Concepts.
 2008 Pearson Education, Inc. All rights reserved JavaScript: Introduction to Scripting.
Information Technology Center Hany Abdelwahab Computer Specialist.
Computer Science 103 Chapter 4 Advanced JavaScript.
Computer Information System Information System California State University Los Angeles Jongwook Woo CIS 461 Web Development I Javascript Jongwook Woo,
Web Development & Design Foundations with XHTML Chapter 14 Key Concepts.
2012 •••••••••••••••••••••••••••••••••• Summer WorkShop Mostafa Badr
Introduction to JavaScript. Aim To enable you to write you first JavaScript.
Introduction to scripting
آموزش طراحی وب سایت جلسه دهم – جاوا اسکریپت 1 تدریس طراحی وب برای اطلاعات بیشتر تماس بگیرید تاو شماره تماس: پست الکترونیک :
JS: DOM Form Form Object Form Object –The Form object represents an HTML form. –For each instance of a tag in an HTML document, a Form object is created.
JavaScript, Fifth Edition Chapter 1 Introduction to JavaScript.
HTML DOM.  The HTML DOM defines a standard way for accessing and manipulating HTML documents.  The DOM presents an HTML document as a tree- structure.
JavaScript Defined DOM (Document Object Model) General Syntax Body vs. Head Variables Math & Logic Selection Functions & Events Loops Animation Getting.
Bridges To Computing General Information: This document was created for use in the "Bridges to Computing" project of Brooklyn College. You are invited.
Week 9 PHP Cookies and Session Introduction to JavaScript.
CSC 330 E-Commerce Teacher Ahmed Mumtaz Mustehsan Ahmed Mumtaz Mustehsan GM-IT CIIT Islamabad GM-IT CIIT Islamabad CIIT Virtual Campus, CIIT COMSATS Institute.
CC1003N Week 6 More CSS and Javascript.. Objectives: ● More CSS Examples ● Javascript – introduction ● Uses of Javascript ● Variables ● Comments ● Control.
Client Scripting1 Internet Systems Design. Client Scripting2 n “A scripting language is a programming language that is used to manipulate, customize,
What is Java Script? An extension to HTML. An extension to HTML. Allows authors to incorporate some functionality in their web pages. (without using CGI.
Javascript. Outline Introduction Fundamental of JavaScript Javascript events management DOM and Dynamic HTML (DHTML)
INTRODUCTION TO JAVASCRIPT AND DOM Internet Engineering Spring 2012.
JavaScript For...In Statement The for...in statement loops through the elements of an array or through the properties of an object. Syntax for (variable.
1 JavaScript in Context. Server-Side Programming.
TUTORIAL 10: PROGRAMMING WITH JAVASCRIPT Session 2: What is JavaScript?
CHAPTER 4 Java Script อ. ยืนยง กันทะเนตร คณะเทคโนโลยีสารสนเทศและการสื่อสาร มหาวิทยาลัยพะเยา 1.
Introduction to JavaScript Basharat Mahmood, Department of Computer Science, CIIT, Islamabad, Pakistan. 1.
Client-Side Scripting JavaScript.  produced by Netscape for use within HTML Web pages.  built into all the major modern browsers. properties  lightweight,
LOGO Introduction to Client-Side Scripting and JavaScript CHAPTER 9 Eastern Mediterranean University School of Computing and Technology Department of Information.
1Computer Sciences Department Princess Nourah bint Abdulrahman University.
1 JavaScript
JavaScript Scripting language What is Scripting ? A scripting language, script language, or extension language is a programming language.
Sahar Mosleh California State University San MarcosPage 1 JavaScript Basic.
CSC318 – DYNAMIC WEB APPLICATION DEVELOPMENT BY: SITI NURBAYA ISMAIL FACULTY of COMPUTER and MATHEMATICAL SCIENCES.
 2000 Deitel & Associates, Inc. All rights reserved. Outline 8.1Introduction 8.2A Simple Program: Printing a Line of Text in a Web Page 8.3Another JavaScript.
By Tharith Sriv. To write a web page you use: HHTML (HyperText Markup Language), AASP (Active Server Page), PPHP (HyperText Preprocessor), JJavaScript,
JavaScript Introduction.  JavaScript is a scripting language  A scripting language is a lightweight programming language  A JavaScript can be inserted.
COMP403 Web Design JAVA SCRİPTS Tolgay KARANFİLLER.
4. Javascript M. Udin Harun Al Rasyid, S.Kom, Ph.D Lab Jaringan Komputer (C-307) Desain.
 2008 Pearson Education, Inc. All rights reserved JavaScript: Introduction to Scripting.
1 JavaScript in Context. Server-Side Programming.
Test Automation For Web-Based Applications Portnov Computer School Presenter: Ellie Skobel.
JavaScript Defined DOM (Document Object Model) General Syntax Body vs. Head Variables Math & Logic Selection Functions & Events Loops Animation Getting.
Pertemuan 5 IT133 Pengembangan Web JavaScript. What is JavaScript? JavaScript was designed to add interactivity to HTML pages JavaScript is a scripting.
CIS 3.5 Lecture 2.3 "Introduction to JavaScript".
JavaScript. JavaScript Introduction JavaScript is the world's most popular programming language. It is the language for HTML and the web, for servers,
JavaScript Lectures Level 7. What is JavaScript? JavaScript was designed to add interactivity to HTML pages JavaScript is a scripting language A scripting.
Web Development JavaScript. Introduction to JavaScript.
This is our seminar JavaScript And DOM This is our seminar JavaScript And DOM.
1 Agenda  Unit 7: Introduction to Programming Using JavaScript T. Jumana Abu Shmais – AOU - Riyadh.
Introduction to Client-Side Scripting and JavaScript
Web Development & Design Foundations with HTML5 7th Edition
My First Web Page document.write("" + Date() + ""); To insert.
4. Javascript Pemrograman Web I Program Studi Teknik Informatika
JavaScript.
WEB PROGRAMMING JavaScript.
PHP.
T. Jumana Abu Shmais – AOU - Riyadh
JavaScript Defined General Syntax Body vs. Head Variables Math & Logic
CS105 Introduction to Computer Concepts
Tutorial 10: Programming with javascript
Web Programming– UFCFB Lecture 13
Web Programming and Design
CS105 Introduction to Computer Concepts JavaScript
Presentation transcript:

JavaScript Introduction JavaScript is the most popular scripting language on the internet, and works in all major browsers, such as Internet Explorer, Firefox, Chrome, Opera, and Safari. The Real Name is ECMAScript JavaScript's official name is ECMAScript. ECMAScript is developed and maintained by the ECMA organization. ECMA-262 is the official JavaScript standard. The language was invented by Brendan Eich at Netscape (with Navigator 2.0), and has appeared in all Netscape and Microsoft browsers since Are Java and JavaScript the same? NO! Java and JavaScript are two completely different languages in both concept and design! Java (developed by Sun Microsystems) is a powerful and much more complex programming language - in the same category as C and C++. Ghazanfar

What is JavaScript?  JavaScript was designed to add interactivity to HTML pages  JavaScript is a scripting language  A scripting language is a lightweight programming language  JavaScript is usually embedded directly into HTML pages  JavaScript is an interpreted language (means that scripts execute without preliminary compilation)  Everyone can use JavaScript without purchasing a license What You Should Already Know Before you continue you should have a basic understanding of the following:  HTML / XHTML Ghazanfar

What can a JavaScript do?  JavaScript gives HTML designers a programming tool - HTML authors are normally not programmers, but JavaScript is a scripting language with a very simple syntax! Almost anyone can put small "snippets" of code into their HTML pages  JavaScript can put dynamic text into an HTML page - A JavaScript statement like this: document.write(" " + name + " ") can write a variable text into an HTML page  JavaScript can react to events - A JavaScript can be set to execute when something happens, like when a page has finished loading or when a user clicks on an HTML element  JavaScript can read and write HTML elements - A JavaScript can read and change the content of an HTML element Ghazanfar

What can a JavaScript do?  JavaScript can be used to validate data - A JavaScript can be used to validate form data before it is submitted to a server. This saves the server from extra processing  JavaScript can be used to detect the visitor's browser - A JavaScript can be used to detect the visitor's browser, and - depending on the browser - load another page specifically designed for that browser  JavaScript can be used to create cookies - A JavaScript can be used to store and retrieve information on the visitor's computer Ghazanfar

Put a JavaScript into an HTML page To insert a JavaScript into an HTML page, we use the tag. Inside the tag we use the type attribute to define the scripting language. The document.write command is a standard JavaScript command for writing output to a page. document.write(" Hello World! "); Ghazanfar

How to Handle Simple Browsers Just add an HTML comment tag (end of comment) after the last JavaScript statement, like this: (//) This prevents JavaScript from executing the --> tag. Ghazanfar

Where to Put the JavaScript 1. Scripts in 2. Scripts in 3. Using an External JavaScript Ghazanfar

JavaScript is Case Sensitive Unlike HTML, JavaScript is case sensitive JavaScript Statements A JavaScript statement is a command to a browser. document.write("Hello Dolly"); JavaScript Code JavaScript code (or just JavaScript) is a sequence of JavaScript statements. document.write(" This is a heading "); document.write(" This is a paragraph. "); document.write(" This is another paragraph. "); JavaScript Blocks Blocks start with a left curly bracket {, and ends with a right curly bracket }. Ghazanfar

JavaScript Comments Comments can be added to explain the JavaScript, or to make the code more readable. /* This is an example of Multi Line comments */ document.write(" This is a heading "); // Example of Single Line comments document.write(" This is a paragraph. "); Single Line & Multiline Comments Ghazanfar

JavaScript Variables As with algebra, JavaScript variables are used to hold values or expressions. A variable can have a short name, like x, or a more descriptive name, like carname. Rules for JavaScript variable names:  Variable names are case sensitive (y and Y are two different variables)  Variable names must begin with a letter or the underscore character Note: Because JavaScript is case-sensitive, variable names are case-sensitive. Ghazanfar

Declaring (Creating) JavaScript Variables You can declare JavaScript variables with the var statement : After the declaration shown above, the variables are empty (they have no values yet). However, you can also assign values to the variables when you declare them: var x; var carname; var x=5; var carname=“Honda”; Ghazanfar

Assigning Values to Undeclared JavaScript Variables If you assign values to variables that have not yet been declared, the variables will automatically be declared. have the same effect as: x=5; carname=“Honda"; var x=5; var carname=“Honda"; Redeclaring JavaScript Variables If you redeclare a JavaScript variable, it will not lose its original value. var x=5; var x; Ghazanfar

JavaScript Arithmetic Operators OperatorDescriptionExampleResult +Additionx=y+2x=7 -Subtractionx=y-2x=3 *Multiplicationx=y*2x=10 /Divisionx=y/2x=2.5 % Modulus (division remainder) x=y%2x=1 ++Incrementx=++yx=6 --Decrementx=--yx=4 Given that y=5, the table below explains the arithmetic operators: Ghazanfar

JavaScript Assignment Operators OperatorExampleSame AsResult =x=y x=5 +=x+=yx=x+yx=15 -=x-=yx=x-yx=5 *=x*=yx=x*yx=50 /=x/=yx=x/yx=2 %=x%=yx=x%yx=0 Given that x=10 and y=5, the table below explains the assignment operators: Ghazanfar

JavaScript Comparison Operators Given that x=5, the table below explains the comparison operators: OperatorDescriptionExample ==is equal tox==8 is false === is exactly equal to (value and type) x===5 is true x==="5" is false !=is not equalx!=8 is true >is greater thanx>8 is false <is less thanx<8 is true >=is greater than or equal tox>=8 is false <=is less than or equal tox<=8 is true Ghazanfar

JavaScript Logical Operators Given that x=6 and y=3, the table below explains the logical operators: OperatorDescriptionExample &&and (x 1) is true ||or(x==5 || y==5) is false !not!(x==y) is true Ghazanfar

JavaScript Conditional Operator JavaScript also contains a conditional operator that assigns a value to a variable based on some condition. Syntax variablename=(condition)?value1:value2 Example greeting=(visitor=="PRES")?"Dear President ":"Dear "; Ghazanfar

The + Operator Used on Strings The + operator can also be used to add string variables or text values together. To add two or more string variables together, use the + operator. txt1="What a very"; txt2="nice day"; txt3=txt1+txt2; After the execution of the statements above, the variable txt3 contains "What a verynice day". To add a space between the two strings, insert a space into one of the strings: txt1="What a very"; txt2="nice day"; txt3=txt1+" "+txt2; After the execution of the statements above, the variable txt3 contains: "What a very nice day" Ghazanfar

Adding Strings and Numbers The rule is: If you add a number and a string, the result will be a string! x=5+5; document.write(x); x="5"+"5"; document.write(x); x=5+"5"; document.write(x); x="5"+5; document.write(x); Result Ghazanfar

Insert Special Characters The backslash (\) is used to insert apostrophes, new lines, quotes, and other special characters into a text string. CodeOutputs \'single quote \"double quote \&ampersand \\backslash \nnew line \rcarriage return \ttab \bbackspace \fform feed Ghazanfar

Conditional Statements Very often when you write code, you want to perform different actions for different decisions. You can use conditional statements in your code to do this. In JavaScript we have the following conditional statements:  if statement - use this statement to execute some code only if a specified condition is true  if...else statement - use this statement to execute some code if the condition is true and another code if the condition is false  if...else if....else statement - use this statement to select one of many blocks of code to be executed  switch statement - use this statement to select one of many blocks of code to be executed Ghazanfar

If Statement Use the if statement to execute some code only if a specified condition is true. if (condition) { code to be executed if condition is true } Syntax If...else Statement Use the if....else statement to execute some code if a condition is true and another code if the condition is not true. if (condition) { code to be executed if condition is true } else { code to be executed if condition is not true } Syntax Ghazanfar

If...else if...else Statement Use the if....else if...else statement to select one of several blocks of code to be executed. if (condition1) { code to be executed if condition1 is true } else if (condition2) { code to be executed if condition2 is true } else { code to be executed if condition1 and condition2 are not true } Syntax Ghazanfar

The JavaScript Switch Statement Use the switch statement to select one of many blocks of code to be executed. switch(n) { case 1: execute code block 1 break; case 2: execute code block 2 break; default: code to be executed if n is different from case 1 and 2 } Syntax Ghazanfar

JavaScript Popup Boxes JavaScript has three kind of popup boxes: Alert box, Confirm box, and Prompt box. Alert Box An alert box is often used if you want to make sure information comes through to the user. When an alert box pops up, the user will have to click "OK" to proceed. alert("sometext"); Syntax Confirm Box A confirm box is often used if you want the user to verify or accept something. When a confirm box pops up, the user will have to click either "OK" or "Cancel" to proceed. If the user clicks "OK", the box returns true. If the user clicks "Cancel", the box returns false. confirm("sometext"); Syntax Khurram

JavaScript Popup Boxes Prompt Box A prompt box is often used if you want the user to input a value before entering a page. When a prompt box pops up, the user will have to click either "OK" or "Cancel" to proceed after entering an input value. If the user clicks "OK" the box returns the input value. If the user clicks "Cancel" the box returns null. prompt("sometext","defaultvalue"); Syntax Khurram

JavaScript Loops Often when you write code, you want the same block of code to run over and over again in a row. Instead of adding several almost equal lines in a script we can use loops to perform a task like this. In JavaScript, there are three different kind of loops:  for loop - loops through a block of code a specified number of times  while loop - loops through a block of code while a specified condition is true  do...while loop - execute the block of code ONCE, and then it will repeat the loop as long as the specified condition is true Khurram

The for Loop The for loop is used when you know in advance how many times the script should run. for (var=startvalue;var<=endvalue;var=var+increment) { code to be executed } Syntax The while loop The while loop loops through a block of code while a specified condition is true. while (var<=endvalue) { code to be executed } Syntax Khurram

The do...while Loop The do...while loop is a variant of the while loop. This loop will execute the block of code ONCE, and then it will repeat the loop as long as the specified condition is true. do { code to be executed } while (var<=endvalue); Syntax Khurram

JavaScript Array An array is a special variable, which can hold more than one value, at a time. If you have a list of items (a list of car names, for example), storing the cars in single variables could look like this: However, what if you want to loop through the cars and find a specific one? And what if you had not 3 cars, but 300? The best solution here is to use an array! An array can hold all your variable values under a single name. And you can access the values by referring to the array name. Each element in the array has its own ID so that it can be easily accessed. cars1=“Honda"; cars2=“Suzuki"; cars3="BMW"; Khurram

Create an Array An array can be defined in three ways. The following code creates an Array object called myCars: 1: var myCars=new Array(); // regular array (add an optional integer myCars[0]=“Honda"; // argument to control array's size) myCars[1]=“Suzuki"; myCars[2]="BMW"; 2: var myCars=new Array(“Honda",“Suzuki","BMW"); // condensed array 3: var myCars=[“Honda",“Suzuki","BMW"]; // literal array Note: If you specify numbers or true/false values inside the array then the variable type will be Number or Boolean, instead of String. Khurram

Access an Array You can refer to a particular element in an array by referring to the name of the array and the index number. The index number starts at 0. The following code line: document.write(myCars[0]); will result in the following output: Honda Khurram

Modify Values in an Array To modify a value in an existing array, just add a new value to the array with a specified index number: myCars[0]="Opel"; Now, the following code line: document.write(myCars[0]); will result in the following output: Opel Khurram

JavaScript For...In Statement The for...in statement loops through the elements of an array or through the properties of an object. for (variable in object) { code to be executed } Syntax Note: The code in the body of the for...in loop is executed once for each element/property. Note: The variable argument can be a named variable, an array element, or a property of an object. Khurram

Example var x; var mycars = new Array(); mycars[0] = “Mercedes"; mycars[1] = “Prado"; mycars[2] = "BMW"; for (x in mycars) { document.write(mycars[x] + " "); } Khurram

Array Functions Join two arrays - concat() var parents = [“Dad", “Mon"]; var children = [“Son", “Daughter"]; var family = parents.concat(children); document.write(family); Output: Dad,Mon,Son,Daughter Khurram

Array Functions (Continue..) Join three arrays - concat() var parents = [“Dad", “Mom"]; var brothers = [“Chachu 1", “Chachu 2”]; var children = [“Son", “Daughter"]; var family = parents.concat(brothers, children); document.write(family); Output: Dad,Mon,Chachu 1,Chachu 2,Son,Daughter Khurram

Array Functions (Continue..) Join all elements of an array into a string - join() var fruits = ["Banana", "Orange", "Apple", "Mango"]; document.write(fruits.join() + " "); document.write(fruits.join("+") + " "); document.write(fruits.join(" and ")); Output: Banana,Orange,Apple,Mango Banana+Orange+Apple+Mango Banana and Orange and Apple and Mango Khurram

Array Functions (Continue..) Remove the last element of an array - pop() var fruits = ["Banana", "Orange", "Apple", "Mango"]; document.write(fruits.pop() + " "); document.write(fruits + " "); document.write(fruits.pop() + " "); document.write(fruits); Output: Mango Banana,Orange,Apple Apple Banana,Orange Khurram

Array Functions (Continue..) Add new elements to the end of an array - push() var fruits = ["Banana", "Orange", "Apple", "Mango"]; document.write(fruits.push("Kiwi") + " "); document.write(fruits.push("Lemon","Pineapple") + " "); document.write(fruits); Output: 5 7 Banana,Orange,Apple,Mango,Kiwi,Lemon,Pineapple Khurram

Array Functions (Continue..) Reverse the order of the elements in an array - reverse() var fruits = ["Banana", "Orange", "Apple", "Mango"]; document.write(fruits.reverse()); Output: Mango,Apple,Orange,Banana Khurram

Array Functions (Continue..) Remove the first element of an array - shift() var fruits = ["Banana", "Orange", "Apple", "Mango"]; document.write(fruits.shift() + " "); document.write(fruits + " "); document.write(fruits.shift() + " "); document.write(fruits); Output: Banana Orange,Apple,Mango Orange Apple,Mango Khurram

Array Functions (Continue..) Select elements from an array - slice() var fruits = ["Banana", "Orange", "Apple", "Mango"]; document.write(fruits.slice(0,1) + " "); document.write(fruits.slice(1) + " "); document.write(fruits.slice(-2) + " "); document.write(fruits); Output: Banana Orange,Apple,Mango Apple,Mango Banana,Orange,Apple,Mango Khurram

Array Functions (Continue..) Sort an array (alphabetically and ascending) - sort() var fruits = ["Banana", "Orange", "Apple", "Mango"]; document.write(fruits.sort()); Output: Apple,Banana,Mango,Orange Khurram

Array Functions (Continue..) Add an element to position 2 in an array - splice() var fruits = ["Banana", "Orange", "Apple", "Mango"]; document.write(“Removed: " + fruits.splice(2,0,"Lemon") + " "); document.write(fruits); Output: Removed: Banana,Orange,Lemon,Apple,Mango Khurram

Array Functions (Continue..) Convert an array to a string - toString() var fruits = ["Banana", "Orange", "Apple", "Mango"]; document.write(fruits.toString()); Output: Banana,Orange,Apple,Mango Khurram

Array Functions (Continue..) Add new elements to the beginning of an array - unshift() var fruits = ["Banana", "Orange", "Apple", "Mango"]; document.write(fruits.unshift(“Grapes") + " "); document.write(fruits.unshift("Lemon","Pineapple") + " "); document.write(fruits); Output: undefined undefined Lemon,Pineapple,Grapes,Banana,Orange,Apple,Mango Note: The unshift() method does not work properly in Internet Explorer, it only returns undefined! Khurram

Example var i=0; for (i=0;i "); } The break Statement The break statement will break the loop and continue executing the code that follows after the loop (if any). Khurram

Example var i=0 for (i=0;i "); } The continue Statement The continue statement will break the current loop and continue with the next value. Khurram

JavaScript Functions To keep the browser from executing a script when the page loads, you can put your script into a function. A function contains code that will be executed by an event or by a call to the function. You may call a function from anywhere within a page (or even from other pages if the function is embedded in an external.js file). Functions can be defined both in the and in the section of a document. However, to assure that a function is read/loaded by the browser before it is called, it could be wise to put functions in the section. function functionname(var1,var2,...,varX) { some code } Syntax Khurram

JavaScript Function Example Example function displaymessage() { alert("Hello World!"); } Khurram

The return Statement Example function product(a,b) { return a*b; } document.write(product(4,3)); The return statement is used to specify the value that is returned from the function. Khurram

JavaScript Events By using JavaScript, we have the ability to create dynamic web pages. Events are actions that can be detected by JavaScript. Every element on a web page has certain events which can trigger a JavaScript. For example, we can use the onClick event of a button element to indicate that a function will run when a user clicks on the button. We define the events in the HTML tags. Examples of events:  A mouse click  A web page or an image loading  Mousing over a hot spot on the web page  Selecting an input field in an HTML form  Submitting an HTML form  A keystroke Note: Events are normally used in combination with functions, and the function will not be executed before the event occurs! Khurram

onLoad and onUnload The onLoad and onUnload events are triggered when the user enters or leaves the page. The onLoad event is often used to check the visitor's browser type and browser version, and load the proper version of the web page based on the information. Both the onLoad and onUnload events are also often used to deal with cookies that should be set when a user enters or leaves a page. For example, you could have a popup asking for the user's name upon his first arrival to your page. The name is then stored in a cookie. Next time the visitor arrives at your page, you could have another popup saying something like: "Welcome John Doe!". Khurram

onFocus, onBlur and onChange The onFocus, onBlur and onChange events are often used in combination with validation of form fields. Below is an example of how to use the onChange event. The check () function will be called whenever the user changes the content of the field: Khurram

onSubmit The onSubmit event is used to validate ALL form fields before submitting it. Below is an example of how to use the onSubmit event. The checkForm() function will be called when the user clicks the submit button in the form. If the field values are not accepted, the submit should be cancelled. The function checkForm() returns either true or false. If it returns true the form will be submitted, otherwise the submit will be cancelled: Khurram

onMouseOver and onMouseOut onMouseOver and onMouseOut are often used to create "animated" buttons. Below is an example of an onMouseOver event. An alert box appears when an onMouseOver event is detected: Khurram

JavaScript Guidelines A function named "myfunction" is not the same as "myFunction" and a variable named "myVar" is not the same as "myvar". JavaScript is case sensitive - therefore watch your capitalization closely when you create or call variables, objects and functions. name=“Khurram"; name = “Khurram"; Syntax White Space JavaScript ignores extra spaces. You can add white space to your script to make it more readable. The following lines are equivalent: JavaScript is Case Sensitive Khurram

JavaScript Guidelines You can break up a code line within a text string with a backslash. The example below will be displayed properly: document.write("Hello \ World!"); Syntax Break up a Code Line However, you cannot break up a code line like this: document.write \ ("Hello World!"); Khurram