JavaScript的学习入门整理篇第1/3页_Javascript教程-查字典教程网
JavaScript的学习入门整理篇第1/3页
JavaScript的学习入门整理篇第1/3页
发布时间:2016-12-30 来源:查字典编辑
摘要:Document.writeln()方法functioncreatesummary(){win2=open("","window2")//w...

<html>

<head>

<metahttp-equiv="Content-Type"content="text/html;charset=gb2312">

<title>Document.writeln()方法</title>

<scriptlanguage="javascript">

functioncreatesummary()

{

win2=open("","window2")

//win2.document.open("text/plain")

win2.document.writeln("title"+document.title)

win2.document.close()

}

</script>

</head>

<body>

<aname="#top"></a>

<form>

<inputtype="button"name="help"value="help"onClick="createsummary()">

</form>

<body>

</html>

说一下知识要点吧:

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

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

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

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

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

Varscope="globle";

functionf(){

alert(scope);//显示“underfined"而不是"globle"

Varscope="local";

alert(scope);

}

F();与下面的代码实例意义相同 Varscope="globle";

functionf(){

Varscope;

alert(scope);//显示“underfined"而不是"globle"

Varscope="local";

alert(scope);

}

F();

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

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

functiondoadd(i){

alert(i);

}

functiondoadd(i){

alert(i);

}

doadd(10);

真正执行的是后一个函数,第二个覆盖了第一个函数;

7:arguments对象的使用。

functiondoAdd()

If(arguments.length==1){

alert(arguments[0]+10);

}

If(arguments.length==2){

alert(arguments[0]+arguments[0);

}

doAdd(10);

doAdd(10,20);

运行效果:略……

当前1/3页123下一页阅读全文

相关阅读
推荐文章
猜你喜欢
附近的人在看
推荐阅读
拓展阅读
  • 大家都在看
  • 小编推荐
  • 猜你喜欢
  • 最新Javascript教程学习
    热门Javascript教程学习
    编程开发子分类