`
dickyzhu
  • 浏览: 107761 次
  • 性别: Icon_minigender_1
  • 来自: 武汉
文章分类
社区版块
存档分类
最新评论

javascript 笔记一

 
阅读更多

一.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"

分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics