Содержание
- 2. A simple Script First JavaScript Page First JavaScript Page document.write(" "); document.write("Hello World Wide Web"); document.write("
- 3. Embedding JavaScript Use the src attribute to include JavaScript codes from an external file. The included
- 4. Popup Boxes Alert box Confirm box Prompts box
- 5. alert(), confirm(), and prompt() alert("This is an Alert method"); confirm("Are you OK?"); prompt("What is your name?");
- 6. The typeof operator typeof operator used to find the type of a JavaScript variable.
- 7. Example
- 8. Undefined data type In JavaScript, a variable without a value, has the value undefined. The typeof
- 9. Null In JavaScript null is "nothing". It is supposed to be something that doesn't exist. Unfortunately,
- 10. Primitive Data
- 11. Complex Data
- 12. Line Breaks To display line breaks inside a popup box, use a back –slash followed by
- 13. JavaScript Objects Objects in real life is for instance Students Properties: name, ID, weigh, height etc.
- 14. JavaScript Objects You have already learned that JavaScript variables are containers for data values.
- 15. Objects Objects are variables too. Objects can contain many values
- 16. Example This code assigns many values (Fiat, 500, white) to a variable named car The values
- 17. Object Properties The name: values pairs are called properties. Property Property value
- 18. Object Methods Methods are actions that can be performed on objects. Methods are stored in properties
- 19. Example
- 20. Accessing Object Properties 2 ways Or
- 21. Accessing Object methods ObjectName.methodName()
- 22. Example
- 23. Do Not Declare Strings, Numbers, and Booleans as Objects! When a JavaScript variable is declared with
- 24. Conditional Statements Very often when you write code, you want to perform different actions for different
- 25. Types of conditional statements if statement - use this statement if you want to execute some
- 26. If statement Syntax and example If (expression) { Statements to be executed if expression is true
- 27. If .. Else statement
- 28. If…else if… statement syntax
- 29. If…else if… statement example
- 30. Switch Statement You should use the Switch statement if you want to select one of many
- 31. Switch statement’s syntax
- 33. The break Keyword When JavaScript reaches a break keyword, it breaks out of the switch block.
- 34. The default Keyword The default keyword specifies the code to run if there is no case
- 35. JavaScript Math Objects allows you to perform mathematical tasks on numbers Math.round(x) returns the value of
- 36. Math Properties (Constants) Math.E // returns Euler's number Math.PI // returns PI Math.SQRT2 // returns the
- 37. JavaScript Random Integers Math.random() used with Math.floor() can be used to return random integers. Math.floor(Math.random() *
- 39. Скачать презентацию