JavaScript Basics Learning

Source: Internet
Author: User

Javascript

DOM Programming---> Manipulating HTML all tags (find HTML file and then manipulate)

JQuery----> Open source Modules (find, operate)


1. Import files

<script type= "Text/javascript" src= "J1.js" ></script>

<!--define a script tag to write JS code--->

<script type= "Text/javascript" >

Func ()

/*--referencing the function func in JS code */

</script>


2, JavaScript placement, generally placed in the HTML page of the body tag at the bottom, CSS can be placed inside the head tag, that is, the head of the HTML page

<! DOCTYPE html>

<meta charset= "UTF-8" >

<title></title>

<body>

<!--import js file src= "j1.js"---->

<script type= "Text/javascript" src= "J1.js" ></script>

<!--define a script tag to write JS code--->

<script type= "Text/javascript" >

Func ()

/*--referencing the function func in JS code */

</script>

</body>



3, comments, single-line comments with//, multiline comments with/*----*/


4. Declaration of variables

Local variable declaration starts with the keyword VAR

For example:

var name= "Eric"

global variable Declaration

For example:

Name= "Alex


5, declare the function passed in parameters, and then directly invoke the execution of their own

(function (ARG) {

Alert (ARG)

}) ("JavaScript")

"


6. Common methods and properties of strings

Obj.trim ()---> Remove spaces from a string

Obj.charat (Index)-------> by string so the subscript gets the corresponding letter

Obj.substring (start,end)-----> intercept a paragraph in a string, or slice

Obj.indexof (char)-------> Find the index value of a character in a string in the middle of a string

Obj.length----------> length of string



7. Arrays

declarations, such as:

var array = array () or var array = []

Add to

Obj.push (ele) append

Obj.unshift (ele) First insertion

Obj.splice (index,0, ' content ') specify index insertion

Removed from

Obj.pop () array trailing fetch

Obj.shift () array header fetch

Obj.splice (index,count) array specifies the position after count characters

Slice

Obj.slice (Start,end)

Merge

NewArray = Obj1.concat (OBJ2)

Flip

Obj.reverse ()

string of

Obj.join ('_')

Length

Obj.length




8. Circulation

var a = ' 123456789 ';

for (Var i=0;i<10;i++) {

Console.log (A[i]);

}<br>

For (var item in a) {

Console.log (A[item]);

}


9. Exception Handling

ty=

}catch (e) {

}finally{

}


This article from "Flat Light is true" blog, please be sure to keep this source http://ucode.blog.51cto.com/10837891/1844234

JavaScript Basics Learning

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.