<javascript Getting Started > Basic grammar

Source: Internet
Author: User

<javascript Getting Started > Basic grammar
First, what is JavaScript? What are the features of the JavaScript language? What are the characteristics of scripting languages?
1, if the CSS is to HTML page make-up decoration to make the HTML page more beautiful, then JavaScript is the HTML in the DOM tree nodes to delete and modify to make the HTML page to achieve dynamic effect.
2, JavaScript language is a kind of object-oriented, weak type, platform-independent, security language. The reason that JavaScript is based on object-oriented is that it is not a purely object-oriented, but an object-oriented object-oriented approach that requires face-to-face process. The weak type of programming language, because he does not need to compile, can be run directly on the browser and thus for the language of classes, functions, variable declarations are not as rigid as in Java. It is platform-agnostic because JavaScript runs on the browser and does not work on any operating system, which is the same as Java running on the JVM that is unrelated to the operating system. It is safe because JavaScript runs on the browser, does not interact with the data on the hard disk, and is more unlikely to modify the data on the hard disk.
3, JavaScript because do not need to compile to run directly, so that he is a scripting language, which is the characteristics of scripting language.
Three ways JavaScript is embedded in HTML
1. First: Because JavaScript is an event-driven programming language, add event handlers to events after an event occurs, add code that needs to be run in the event handle, and run the code through event-driven triggering event handlers. The code that is written in the event handle is the JavaScript code.
2. Second type: script block
3. The third type: SRC Import external file
Iii. basic JavaScript syntax
keywords, identifiers, data types, functions (called functions, which are different from Java methods), variables
Iv. global variables and local variables for JavaScript
In three cases: 1, all without the VAR keyword is a global variable
2, written in the function body with the VAR keyword is a global variable
3, written in the function body with the VAR keyword is a local variable
V. JavaScript data types and their corresponding built-in methods
1. JavaScript data types are divided into basic data types and reference data types.
Base data type: Undefined,number,string,boolean
Reference type data: Object and its subclasses
2, Undefined type has only one value: keyword Undefined cannot be quoted, add quotation marks is the string and the keyword Undefined no relationship
Vi. differences between JavaScript's typeof operator, void operator, = and = = and = = =
1, typeof determine what type of data
2, void used in the Forbidden page to jump
For example: <a href= "" onclick= "alert (' Hello ')" > This code when the mouse clicks because there is no hyperlink address, so the default is a point. Represents the current page, actually the page is still reloaded. </a>
If you set the hyperlink address <a href= "http://cnblogs.com" onclick= "alert (' Hello ') > then the mouse click will jump to the hyperlink page </a>
Void's role is to discard hyperlinks, so that when the mouse click to produce an event handle effect but stay on the current page, the specific code <a href= "javascript:void (0) onclick=" alert (' Hello ') ">
3 = Assignment = = Determine whether the contents of two variables are the same (data types can be different)
= = = Determines whether the content of the two variables is the same as the data type

Vii. three ways to define arrays in JavaScript
The first: Var arr=[];//creates an array of length 0
var arr=new array ();//Create an array of length 0
The second type: var arr=[1,2,3,4];//creates an array of length 4 and determined by each element
var arr=new Array (1,2,3,4);
var arr=new Array ("abc", "SDF", "SDA");
The Third kind: var arr=new array (4);//This represents the length of the current array, which is currently an array of length 4, with no elements in the array

<javascript Getting Started > Basic grammar

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.