javascript 笔记一

xiaoxiao2026-05-25  11

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

相关资源:JavaScript基础笔记-尚硅谷视频自己总结
转载请注明原文地址: https://www.6miu.com/read-5049383.html

最新回复(0)