Basic JavaScript essentials

Source: Internet
Author: User

JavaScript (JS) is a literal script language , which is a dynamic type, a weak type, a prototype-based language, and a built-in support type. Its interpreter, known as the JavaScript engine, is widely used as a scripting language for clients in the browser, and is used on HTML pages to add dynamic functionality to HTML pages.

Speaking of JavaScript, what does JavaScript say?

JavaScript is a descriptive voice and is a basic object (that is, object) and an event-driven scripting language with security performance.

So what are the advantages of using JavaScript?

Here's a summary of the advantages of javascript:

(1) JavaScript primarily adds interaction behavior to HTML pages.

(2) JavaScript is a scripting language, and syntax is similar to java.

(3) JavaScript is typically used to write client-side scripts.

(4) JavaScript is an explanatory language that performs edge interpretation. What is JavaScript made of?

(1) ECMAScript standard

ECMAScript is an open, internationally accepted scripting specification .

(2) Browser object model

The browser object model provides an object that is independent of the content interacting with the browser window, using a browser model to interact with the HTML.

(3) Document Object model

The Document Object model is a standard set of methods used to access and manipulate HTML documents in the HTML Document Object model.

Data types for javascript:

Undefined Type not defined
Null Empty type
Number Numeric type
String String type
Boolean Boolean type

Said so much, presumably everyone is tired of watching, the following code to go,

The basic structure of javascript:

1 <script type= "Text/javascript" >23 <!--JavaScript statement;-->45 </Script>

and two ways to add an array element :

 1  //  2  var  array=[' A ', ' B ' ]; 3   the second  4  var  array=new  Array (' A ', ' B '  5   the third  6  var  array=new   Array ();  7  array[0]= ' A '  8  array[1]= ' B '; 

What if you want to output a paragraph on a webpage? So long you can use the alert () method to make the output on the page

Here's the syntax:

1 alert ("What you want to output");

Use alert (), or the method can write a custom method or variable name in the output content.

Custom functions (can also be seen as a method)

JavaScript needs to define a function before it can call a function. Defining a function in JavaScript consists of a keyword function, a function name, a set of parameters, and a pending JavaScript statement that is placed in parentheses.

Grammar:

1  Function name (parameter 1, parameter 2, Parameter 3,...) <!--can also have no parameters, default no return value-2{3          4         [ return value]5  }

Calling functions

Grammar:

Event name = "function name ()";

anonymous functions

  Because the entire statement defined by an anonymous function can be saved as a value for a variable, an anonymous function is called using the variable name.

1 function () 2 {3     <!--javascript statements--4 }

Calling anonymous functions

Grammar:

<!--declare a variable, save the anonymous function so that the statement--andvar function () {            <!--method content --        }

Basic JavaScript essentials

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.