Gjm:javascript Language Learning Notes

Source: Internet
Author: User

Javascript
------------------------------
Variable declaration: Var A;
Variable assignment: var a = 12;

function declaration: var mawesomefunction = function myargument) {}
Function call: Mawesomefunction (something);

function as a function parameter passed into another function

Declaring a function 1 square = function (a) {return a * A;}
Declaring a function 2 applyoperation = function (f,a) {return F (a);}
Call function 2 to pass function 1 as a parameter into function 2
Applyoperation (square,10);

return value

MyFunction = function (a) {
return A;
Explodecomputer (); This sentence because the last sentence has return will not execute}

IF
if (foo) {return bar;}

If/else
if (foo) {function1 ();}
else {function2 ();}

If/else conditional judgment as a line

Foo? Function1 (): function2 ();
If Foo is established return function1 function otherwise return function2 function

Variable Assignment Example: var n = foo? 1:2;
"When Foo is true, the value of n is assigned to 1, otherwise it is 2

Else If to handle more types of judgments
if (foo) {function1 ();}
else if (bar) {function2 ();}
else {Function3 ();}

Javescript Arrays (Array)

Array declaration a = [123,456,789];
Array access a[1]; Returns 456

Javescript Objects (object)

Myprofile = {
Name: "Jare Guo",
Emmail: "[email protected]",
"Zip Code": 123456,
Isinvited:true}
Key is the property name and value is the property value

Gjm:javascript Language Learning Notes

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.