JavaScript for C#Developers Study(1)

JavaScript Basics

  • Special number values

Note:

    1. 10/0 doesn’t throw exception, it returns NaN instead
    2. NaN doesn’t equal to NaN
    3. use isNaN function to test NaN
    4. isNaN will coalesce string of number

image

 

  • Flow-control statements apply coalescing to boolean

In logical expression, the following values will be treated as false:

    1. empty string
    2. number 0
    3. NaN
    4. null
    5. undefined

Otherwise, true

For example, we don’t need to write if(a == null) to test, instead, we simply write if(a)

image

 

  • Reference  Types

image

    • Object Literals

image

    • Array Literals

image

    • Array is an Untyped collection which can hold different type of object inside of it

image

  • Function is a type like Func<> in c#, it can be assigned to a variable.

image

posted @ 2012-10-19 02:53  Jian, Li  Views(229)  Comments(0)    收藏  举报