Basic Javascript: Beihai Collection & lt; 1 & gt;

Source: Internet
Author: User

1. javascript is a weak type and does not distinguish between numeric types. variables are defined using Var.

2. NaN = Not a Number

3. Alert (234 + "123") returns 234123. Weak type bias ." + The "sign is converted to the string type.

4. Alert (1 + 2 + "3" + 4 + 5) returns result 3345. + During the process, it is found that all strings are converted to strings

5. Alert (true> false) returns true. True is converted to 1, and flase is converted to 0.

6. Alert (3 & 4) returns Result 4. Fast and

7. Alert (!!"") The returned value is false. Alert ("Hello" & ") returns "",!! Returns the current Boolean value.

8. Prompt ("enter a number", "Default Value "). The Prompt is used to receive user input.

9. Javascript does not support annotation nesting. That is :/*/*... . There is no elseif syntax.

10. for (;) {} is allowed, but it enters an endless loop.

11. function Definition Format: function funcName (parameter 1, parameter 2) {function body} can be called multiple times, and the location is not fixed.

12. global variables can be accessed in all places. Function Local variables that can be accessed in the function.

13. Var d = new Date (); alert (d. Method Name (); create a new object and call the object method.

14. d. Month (); the Month starts from scratch. D. getDay (); returns the day of the week, and returns 0 on Sunday.

15. Var a = new Array (); or Var d = []; create an Array a [0] = 1; a [1] = "asd "; a [1] = true; dynamic type. An array is an extension of an object.

16. Var a = new Array (,); set the initial value Var a = new Array (3); set the length of the Array parameter (Var d = []; not supported)

17. Var l = d. Push (123,456,789); // add elements to the end of the array. The returned value is the new array length.

18. Delete d [1]; // The method for deleting array elements without affecting Length changes.

19. d. join ("#"); // Insert the specified separator d. shift () to the array; remove the first element of the array.

20. The object is in the form of name-value, which appears in pairs.

21. Var obj = new Object (); Var obj = {name = "CJ", "age": 18}; // Object declaration.

22. Var temp = Obj. name; Var temp = Obj ["age"]; Var temp = Obj [1]; // attributes supported by the object Value colleagues, string subscript, and numeric subscript.

23. Objects in Javascript are similar to arrays, but there are no methods specific to arrays such as length, push, and join.

24. The Replace, substring, and substr methods do not change the original string and are returned as return values.

25. innerHTML indicates the HTML contained in the HTML Tag.

 

From the straw from the reed

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.