ExtJS Basic--function The method that can be executed at the time of definition Function () {...} ()

Source: Internet
Author: User

The function () of the method that can be executed when the function is defined in Ext.js () {...} () JS Code
  1. /**
  2. * Part Two function: The function of the method that can be executed at the time of definition () {...} (); Note that after the red parenthesis , the function definition, the price brackets are defined and then executed
  3. */
  4. /**
  5. * I. Definition and execution of common methods
  6. */
  7. 1-1, normal method definition, without the return value of the case
  8. Fun = function () {
  9. Alert ("execute");
  10. };
  11. 1-2, normal method execution, without the return value of the case
  12. Fun ();//output Result: Execute
  13. 2-1, normal method definition, with return value, and the return value is a string case
  14. Fun = function () {
  15. Alert ("execute");
  16. Return "is the string returned";
  17. }
  18. 2-2, normal method execution, with the return value, and the return value is a string case
  19. Fun ();//output Result: Execute
  20. 2-3, the normal method executes, with the return value, and the return value is a string case, and the return value output
  21. Alert (fun ());//output: Execute, return the string, (two warning boxes appear), because the fun () is executed first, and then bring back the returned string, and then through the alert output
  22. Alert (typeof fun ());//Output Result: Execute, string
  23. 3-1, normal method definition, with return value, and the return value is an object case
  24. Fun = function () {
  25. Alert ("execute");
  26. return new Date ();
  27. }
  28. 3-2, normal method execution, with the return value, and the return value is an object case
  29. Fun ();//output Result: Execute
  30. 3-3, the normal method executes, with the return value, and the return value is an object case, and the return value output
  31. Alert (fun ());//Output Result: Execute, Wed may 16:25:32 utc+0800 2008
  32. 3-4, the normal method executes, with the return value, and the return value is an object case, and the return value type output
  33. Alert (typeof fun ());//Output Result: Execute, Object
  34. 4-1, normal method execution, with the return value, and the return value is a function of the case
  35. Fun = function () {
  36. Alert ("execute");
  37. return function () {
  38. Alert ("return type is a method");
  39. };
  40. }
  41. 4-2, normal method execution, with the return value, and the return value is a function of the case
  42. Fun ();//output Result: Execute
  43. 4-3, because Fun () is returned after execution of a function, so according to the function of the returned parameter conditions (such as the number and type of parameters) to perform a return function,
  44. Because the returned function here does not require parameters, it can be executed directly with ().
  45. Fun () ();//Output result: execution, return type is a method
  46. 3-4, the normal method executes, with the return value, and the return value is an object case, and the return value type output
  47. Alert (typeof fun ());//Output Result: Execute, function
  48. /**
  49. * Can be executed when defined
  50. */
  51. Fun = function () {
  52. Alert ("execute");
  53. }();
  54. alert (fun);
  55. Fun = function () {
  56. Alert ("execute");
  57. Return "is the string returned"; A string is returned.
  58. }();
  59. Alert (Fun)
  60. Fun = function () {
  61. Alert ("execute");
  62. return new Date (); It returns an object.
  63. }();
  64. alert (fun);
  65. Fun = function () {
  66. Alert ("execute");
  67. return function () {
  68. Alert ("return type is a method");
  69. }//Returned is a method
  70. }();
  71. Fun ();

Original link: http://yahaitt.iteye.com/blog/193054

ExtJS Basic--function The method that can be executed at the time of definition Function () {...} ()

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.