程序代写 IE10 and IE11.

JavaScript – Basics
Copyright © Ellis Horowitz 1999-2022 JS Basics 1

What is JavaScript

Copyright By PowCoder代写 加微信 powcoder

• JavaScript is a “simple”, interpreted, programming language with elementary object- oriented capabilities
• JavaScript has two distinct systems –client-side JavaScript runs on Web browsers –server-side JavaScript runs on Web servers
• JavaScript syntax resembles C, C++, and Java
• Developed in 10 days by at Netscape in May 1995 (now CEO at Brave Software after serving as cofounder and CTO at Mozilla)
• The original name was Mocha, chosen by , founder of Netscape
• Was renamed as LiveScript, then JavaScript • See ”A Short History of JavaScript”:
https://www.w3.org/community/webed/wiki/A_Sh
ort_History_of_JavaScript
Copyright © Ellis Horowitz 1999-2022 JS Basics 2

JavaScript is Embedded in HTML
• In the


Copyright © Ellis Horowitz 1999-2022 JS Basics 3

A Simple Example
Simple Javascript

First Example of JavaScript



Copyright © Ellis Horowitz 1999-2022 JS Basics 4

Example 1: Browser Output
Copyright © Ellis Horowitz 1999-2022 JS Basics 5

Another Example
Computing Factorials

Another Example of JavaScript



The date and time are



Copyright © Ellis Horowitz 1999-2022 JS Basics 35

Using alert(), confirm(), and prompt()
welcome to this page





Copyright © Ellis Horowitz 1999-2022 JS Basics 36

Example 5: Browser Output
Copyright © Ellis Horowitz 1999-2022 JS Basics 37

Clicking on confirm()
Copyright © Ellis Horowitz 1999-2022 JS Basics 38

Clicking on prompt()
Copyright © Ellis Horowitz 1999-2022 JS Basics 39

Final Thoughts – Common Mistakes 1. Undefined may not be null
– In JavaScript something that has not been assigned to is not null, but undefined. Undefined is different from null when using != = but not when using the weaker != because JavaScript does some implicit casting in the later case
– For details see http://javascript.about.com/od/hintsandtips/a/Null-And- Undefined.htm
2. You cannot overload a function
– If you try to define two different functions with the same name but with different arguments, assuming the proper function will be called when the number of arguments match (this is overloading), then your assumption is incorrect. JavaScript will simply use the latest-defined version of the function and call it;
– If a parameter is omitted, it is undefined
3. Undeclared variables are global
– If a variable is NOT declared using var, then it is global. Two variables of the same name, both undeclared will create conflicts that are hard to debug

程序代写 CS代考 加微信: powcoder QQ: 1823890830 Email: powcoder@163.com