js--of variables and functions, anonymous functions, function arguments, return

Source: Internet
Author: User

Tag: Is the set htm utf-8 turn fine col parameter btn

The JS parsing process is divided into two stages: the compile stage and the execution stage. The Declaration and definition of function functions are advanced in the compilation phase, and the declaration of VAR is advanced, and the variable defined by VAR is assigned a value of undefined.

Anonymous functions:

Window.onload = function () {            var oBtn01 = document.getElementById (' Btn01 ');            var oBtn02 = document.getElementById (' btn02 ');            Note that there can be no parentheses, Skin01 () immediately executed oh, so do not add ()!            Obtn01.onclick = Skin01;            Obtn02.onclick = skin02;        }

This is an anonymous function, without a name ~

function arguments (similar to Python ~):

<!DOCTYPE HTML><HTMLLang= "en"><Head>    <MetaCharSet= "UTF-8">    <title>Title</title>    <Scripttype= "Text/javascript">window.onload= function () {            varOdiv=document.getElementById ('Div1'); Changestyle ('Color','Gold'); Changestyle ('background','Hotpink'); Changestyle ('width','300px'); Changestyle ('Height','300px'); Changestyle ('margin','50px Auto'); functionChangestyle (styl,val) {Odiv.style[styl]=Val; }        }    </Script></Head><Body><DivID= "Div1">div element</Div></Body></HTML>

Function parameters:

Window.onload = function () {    var oBtn01 = document.getElementById (' Btn01 '); var oBtn02 = document.getElementById (' Btn02 ');//Note there can be no parentheses, Skin01 () immediately executes the oh, so do not add ()! Obtn01.onclick = Skin01;obtn02.onclick = skin02;}

return keyword effect:

1) return function execution result;

2) End Function operation;

3) block default behavior.

js--of variables and functions, anonymous functions, function arguments, return

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.