JavaScript Primer Prerequisites

Source: Internet
Author: User

1.JavaScript is not related to Java, JavaScript is a (customer-side) scripting language and is an explanatory language.

2. Ways to add JavaScript

(1) Inline: via <SCRIPT>JS code </script>

(2) Outreach: Through <script src= "JS path" ></script>

(3) Link to a JS file via UPL

(4) Add JS code directly in the event handler

3.JAVASCRIPT5 basic Data type: Null,nudefined,string,number,

Boolean

String string data type, which is added to any data type and converted to a string data type

4. Creation of arrays

(1) Create by object

var arr=array ();

(2) through special symbols (only square brackets, parentheses, curly braces are illegal)

var arr=[];

5. function return value, if not set, returns undefined by default, as follows:

function text (num) {

if (num>=3) {

return 7;

}}

var i=text (1);

alert (i)//output undefined

6. Objects and Classes

A class is an abstraction of an object that is an instance of a class

3 main features of object-oriented programming : Inheritance, encapsulation, polymorphism

(1) through a point you can

syntax: Object name . Properties

(2) object name [" property name "]

7.JavaScript Built-in objects: The class that is packaged in JavaScript.

the built-in objects in JavaScript are roughly an Array,Boolean,Date,Math ,number,String,RegExp,Function , Events

In addition to the built-in objects described above, a new built-in object is introduced here:Global

before we used the parseint (), parsefloat () These methods, in fact, are The methods of the global object.

here is an eval () method, a method of the global class

Eval ("alert (' Hello ')");//The method parses the string passed in

several ways to get elements in 8.DOM

(1) getElementById ("id")

(2) Getelementbyname ("name")

(3) GetElementsbytagname (" label name ")

(4) GetElementsbyclassname ("Class name ")

9.DOM method for creating ELEMENT nodes:createelement ()

Add the newly created element node to the document:appendchild () and insertbefore ()

need to figure out InnerHTML,innerText,value,nodevalue the difference between

two ways to stream events within 11.JavaScript: bubbling and capturing

12. How to submit a form

(1) Submit via Submit button (type=submit,type=image)

(2) The Submit () method of the Form object can also submit the form

in the inside JavaScript, the form is treated as an object by default

Form Object . Submit ()

The number is an instance object belonging to the array, which is an instance object belonging to the array, and the string is an instance object of String. Null is an instance object that belongs to

14. 3 ways to bind events:HTML event handler,DOM0 level,DOM2 level

The disadvantage of the DOM0 level: cannot bind multiple, if the binding multiple, the subsequent event will overwrite the previous event

The difference between 15.== and = = =

= = value Equal = = value and type are equal

There is a test method inside the regular expression

Var reg = self-written regular expression

Reg.test ( the string that you want to match )

if satisfied, returns trueif not satisfied, returns false

JavaScript Primer Prerequisites

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.