C # Development 2 --- front-end technology javascript

Source: Internet
Author: User

C # Development 2 --- front-end technology javascript
1. The usage can be written in the head or body tag of html. The execution sequence is from top to bottom. 1. directly use <script type = "text/javascript"> </script> 2. Call external javascript <script src = "out. js "type =" text/javascript "> // out. js is the external js name. </Script> 3. Directly reference <a href = "javascript: alert ('test data') in html ') "> I am a js link </a> // The javascrtipt here is similar to the Protocol. For example, to link to FTP, mail requires the keyword ftp. Ii. javascript Syntax 1. Variable declaration var I // local variables, which are valid in the method body. You do not need to specify the variable type. I // If var is not added, it is a global variable that is valid on the entire html page. This is not recommended. Js variables have dynamic types, that is, the same variable can be used as different types. For example, var I = 6; var I = "I Am a js variable". 2. There is a data type in data-Type js, but you do not need to specify a type when declaring a variable. (1) single quotation marks or double quotation marks are used for string types. Var I = 'I am a js variable'; // It is enclosed in single quotes. (2) number var I = 2; var I = 3.14; (3) Boolean has only two values: true and false var I = true; var j = false; (4) array var j = new arry (); // declare array j [0] = "Hubei"; // assign a value to the array. J [1] = "Jiangsu" varj = new arry ("Hubei", "Jiangsu") // assign values directly. (5) undefined and null // It is not a keyword. It is an attribute undefined: Unknown state, without a value. When the method does not return a value, undefined is returned by default. Var B; // B is in the undefined state. It does not contain values. Null: Non-stored objects. You can also assign a null value to the variable. Empty the variable. (6) object (7) summary can declare the type of the variable in this way. Var carname = new String; var x = new Number; var y = new Boolean; var cars = new Array; var person = new Object; iii. method 1. General Method fuction tall (I, j) {// The parameter can have a non-method body return a; // the return value can have none} 2. Anonymous method fuction () {} example: var f = fuction (a1, a2) {} f (); // indicates that anonymous functions are called. 4. Objects and js classes do not have the concept of classes, simulate the class fuction tall (I, j) {// The class here is a bit similar to the constructor in the class, and assign the initial value to the field in the class. This. a = I; this. B = j;} var f = new tall (); // this is the object of the class. Without adding a new object, the above is a method, and the above is a class. 5. array var j = new arry (); 6. jason

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.