Javascript: C and Draw Essays

2139 Words Mar 22nd, 2009 9 Pages
INTRODUCTION TO JAVASCRIPT {draw:rect} 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 A JavaScript consists of lines of executable computer code A 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 {draw:rect} 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 …show more content…
There is a 50% chance for each of them. {draw:rect} 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 if you want to execute some code only if a specified condition is true if...else statement - use this statement if you want 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 if you want to select one of many blocks of code to be executed switch statement - use this statement if you want to select one of many blocks of code to be executed {draw:rect} If Statement You should use the if statement if you want to execute some code only if a specified condition is true. Syntax Note that if is written in lowercase letters. Using uppercase letters (IF) will generate a JavaScript error! Example 1 Example 2 Note: When comparing variables you must always use two equals signs next to each other (==)! Notice that there is no ..else.. in this syntax. You just tell the code to execute some code only if the specified condition is true. {draw:rect} If...else Statement If you want to execute some code if a condition is true and

Related Documents