javascript入门学习:JavaScript的学习入门整理篇

<html>
<head>
<meta http-equiv="Content-Type" content="text/html;char=gb2312">
<title>Document.writeln思路方法</title>
<script language="javascript">
function createsummary
{
win2
=open("","window2")
//win2.document.open("text/plain")
win2.document.writeln("title"+document.title)
win2.document.close
}
</script>
</head>
<body>
<a name="#top"></a>
<form>
<input type="button" name="help" value="help"onClick="createsummary">
</form>
<body>
</html>

下知识要点吧:

1:JavaScript是种区分大小写语言

2:建议每写行要用‘;';

3:命名第个字母必须是字母、下划线或‘$';

4:在JavaScript中声明变量用var而且是永久性

5:没有块级作用域例如:

Var scope="globle";
function f{
alert(scope);
//显示“underfined"而不是"globle"
Var scope="local";
alert(scope);
}
F;


和下面代码例子意义相同 Var scope="globle";
function f{
Var scope;
alert(scope);
//显示“underfined"而不是"globle"
Var scope="local";
alert(scope);
}
F;


建议:将所有变量声明集中起来放置在开头是个很好编程习惯

6:ECMAScript标准中规定不能重载例如



function doadd(i){
alert(i);
}
function doadd(i){
alert(i);
}
doadd(
10);

真正执行是后第 2个覆盖了第

7:arguments对象使用

function doAdd
If(arguments.length
1){
alert(arguments[
0]+10);
}
If(arguments.length
2){
alert(arguments[
0]+arguments[0);
}
doAdd(
10);
doAdd(
10,20);

运行效果:略……
Tags:  javascript学习 javascript入门经典 javascript入门 javascript入门学习

延伸阅读

最新评论

发表评论