JS Design Pattern Notes

Source: Internet
Author: User

A full-expressive javascript

JavaScript is a weakly typed language. When you define a variable, you do not need to declare its type.

JavaScript type: Primitive type: Numeric type, Boolean, String type.

The type of the object, the type of function that contains the executable code, the empty type, and the undefined type.

  

JS in the function is a class citizen. Can be stored in variables, as parameters, as a return value, can be dynamically constructed.

anonymous function: function () {} to create functions without names

Functions to be executed immediately: (function ()

{var a=10;alert (a*10);} ) ();

Pass parameter: (function (A, B)

{alert (a*b);} ) (10,5);

An important use of anonymous functions is to create closures. Closures are a protected variable space that is generated by inline functions.

JavaScript has a function scope and cannot access internal variables outside the function.

The scope of JavaScript is lexical in nature. A variable is run in the scope it defines, not in the scope it is called.

var globv

(function () {

var a=10;

var b=20;

GLOBV =function () {

return a*b;}

})();

GLOBV ();

JS Design Pattern Notes

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.