JavaScript Learning Notes (5)

Source: Internet
Author: User
Tags javascript array

JavaScript functions

A function is an event-driven or reusable block of code that executes when it is invoked

JavaScript function syntax

function functionname (parameter list) {Here is the code to execute
return value}

  

In JavaScript, variables are divided into local variables and global variables

A variable declared inside a JavaScript function is a local variable that can only be accessed inside a function

You can use the same local variable in different functions, because only functions that have declared the variable will recognize it

When the function is finished, the local variable is deleted

Variables declared outside of a function are global variables, and all scripts and functions in a Web page can use it

The life cycle of JavaScript variables

The life cycle of JavaScript variables begins when they are declared

Local variables are destroyed after the function has finished running

Global variables are destroyed after the page is closed

  

In JavaScript, if you assign a value to an undeclared variable, the variable is automatically declared as a global variable

Study for two days of JavaScript, before the course has not been completed before the completion of a test, found that they are still a knowledge point of omission

Here is the result of the test:

1. Which of the following HTML elements can we place Javascript code in? Your answer: <script>2. What is the correct Javascript syntax for writing "Hello World"? Your answer: document.write ("Hello World") 3. Where is the correct location for inserting javacript? Your answers are available in both the:<body> section and the 

From the above test, the problem is that the basic content of JavaScript (output, statements, comments, variables, data types, objects, functions, operators, etc.) is very easy for people with a certain program language base (especially C language).

  

JavaScript Learning Notes (5)

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.