javascript 笔记一

来源:互联网 发布:单片机流水灯 编辑:程序博客网 时间:2024/05/16 17:20

一.javascript 的函数定义方式:

方式1.

     function square(x) {

         return x*x;

    }
方式2.

    var square = function(x) { return x*x; }

方式3.

    var square = new Function("x", "return x*x;");//not often useful

 

二.Object

1.创建对象:

 方式一.

     var point= new Object();

     point.x=2.3;

     point.y=-1.2;

 方式二.

     var point = { x:2.3, y:-1.2 };
2.When a non-null object is used in a Boolean context, it converts to true.


三.Array

1.JavaScript does not support multidimensional arrays.

 

2.When a variable holds the value null, you know that it does not contain a valid object, array, number, string, or boolean value.

 

3.undefined is returned when you use either a variable that has been declared but never had a value assigned to it or an object property that does not exist.

 

4.When the undefined value is used in a Boolean context, it converts to false. When used in a numeric context, it converts to NaN. And when used in a string context, it converts to "undefined"

原创粉丝点击