JavaScript First Contact

Source: Internet
Author: User

JavaScript is a weak object language. The top-level object is window. Each HTML is represented by a Window object, and each window is not directly affected by each other.

Difference from J A V A

1. The variable has no type.

2. The comparison budget symbol has a strict comparison. and no | and & Only | | and &&

3.js has functions, and Java is a method. But the way you define it is different.

The 4.if statement has a bit of a special place. if (999) You can also execute the IF code. The Java expression is executed only if it is true.

Scope of the variable:
The variable declared within the 1.<script> tag is a global variable, which is valid for the entire page's JS code.
2.JS pre-defined variables such as Name.value without var. direct alert (typeof name);
The 3.js engine places the global variables at the top of the assignment statement before the code executes.
alert (i); var i=9;/ This is shown as undefined
4.if and local variables in the loop are promoted to global variables regardless of whether they are executed or not.
Only if not executed, the variable value is undefined////
5. Variables can be declared repeatedly, using the last assignment before.
6. Variables defined within functions are not prompt for global variables, external inaccessible
7. Two nested functions, the outer layer of the variables defined by the internal effect, the inner layer of the external layer is invalid,
Same as the 6 principle. The inner layer is a relationship inside and outside of a function relative to the outer layers./////

JS does not have the same data type as java.

JS number type only one Number.java has an int short float.double.long.

JSON JavaScript Object Notation
JS Specification: An object is represented by a {}
{"Key1": value1, "Key2": vlue2} key is enclosed in double quotes, key and value are separated by a colon, and different keys are separated by commas.

how function is created;

1. Function name (parameter) {function Body}; Called by name ().

2.var i=function (parameter) {function Body}; Call through I ()

3.var i=new Function (parameter, functional body) I () call.

called. function name (); JS will scan all the code before using it. Then the function declaration is all managed. JS has no overloaded concepts, and later declared functions overwrite previously declared functions.

function A () {
var i=0; var b= function () {var m=i;alert (m);}
I=10;b ();//function executes only when execution is performed. This is where function is prone to error.
}
A ();
function A () {
var I=0;var b=function () {alert (B.I);}
B.i=i;i=10;b ();} A ();//This is where the value of the previous i is stored as a property of B.

The array of JS is variable length.

Creation of JS object;

1.var i=new Object ();

2.JSON JavaScript Object Notation
JS Specification: An object is represented by a {}
{"Key1": value1, "Key2": vlue2} key is enclosed in double quotes, key and value are separated by a colon, and different keys are separated by commas.

JavaScript First Contact

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.