JS有什么关键字

JavaScript09

JS有什么关键字,第1张

1.document.write("")输出语句 2.JS中的注释为// 3.传统的HTML文档顺序是:document->html->(head,body) 4.一个浏览器窗口中的DOM顺序是:window->(navigator,screen,history,location,document) 5.得到表单中元素的名称和值:document.getElementById("表单中元素的ID号").name(或value) 6.一个小写转大写的JS: document.getElementById("output").value = document.getElementById("input").value.toUpperCase()7.JS中的值类型:String,Number,Boolean,Null,Object,Function 8.JS中的字符型转换成数值型:parseInt(),parseFloat() 9.JS中的数字转换成字符型:(""+变量) 10.JS中的取字符串长度是:(length) 11.JS中的字符与字符相连接使用+号. 12.JS中的比较操作符有:==等于,!=不等于,>,>=,<.<= 13.JS中声明变量使用:var来进行声明 14.JS中的判断语句结构:if(condition){}else{} 15.JS中的循环结构:for([initial expression][condition][upadte expression]) {inside loop} 16.循环中止的命令是:break 17.JS中的函数定义:function functionName([parameter],...){statement[s]} 18.当文件中出现多个form表单时.可以用document.forms[0],document.forms[1]来代替. 19.窗口:打开窗口window.open(), 关闭一个窗口:window.close(), 窗口本身:self 20.状态栏的设置:window.status="字符"21.弹出提示信息:window.alert("字符")22.弹出确认框:window.confirm()23.弹出输入提示框:window.prompt()24.指定当前显示链接的位置:window.location.href="URL" 25.取出窗体中的所有表单的数量:document.forms.length 26.关闭文档的输出流:document.close()27.字符串追加连接符:+= 28.创建一个文档元素:document.createElement(),document.createTextNode() 29.得到元素的方法:document.getElementById()30.设置表单中所有文本型的成员的值为空: var form = window.document.forms[0] for (var i = 0i<form.elements.lengthi++){ if (form.elements.type == "text"){ form.elements.value = ""} } 31.复选按钮在JS中判断是否选中:document.forms[0].checkThis.checked (checked属性代表为是否选中返回TRUE或FALSE) 32.单选按钮组(单选按钮的名称必须相同):取单选按钮组的长度document.forms[0].groupName.length 33.单选按钮组判断是否被选中也是用checked. 34.下拉列表框的值:document.forms[0].selectName.options[n].value (n有时用下拉列表框名称加上.selectedIndex来确定被选中的值) 35.字符串的定义:var myString = new String("This is lightsword")36.字符串转成大写:string.toUpperCase()字符串转成小写:string.toLowerCase()37.返回字符串2在字符串1中出现的位置:String1.indexOf("String2")!=-1则说明没找到. 其余看 http://pro-ygw.javaeye.com/blog/32517

实质上没有区别。

“关键字”就是 JS 本身已经使用了,具有一定特殊的含义,你就不能再用它们充当变量名啊方法名啊什么的。包括(按字母排序):break、case、catch、continue、default、delete、do、else、finally、for、function、if、in、instanceof、new、return、switch、this、throw、try、typeof、var、void、while、with 等。

“保留字”实际上就是预留的“关键字”,意思是现在虽然现在还不是关键字(也就是本身还不具备特殊含义的),但是未来可能会成为关键字的,你一样是不能使用它们当变量名啊方法名的。包括(按字母排序):abstract、boolean、byte、char、class、const、debugger、double、enum、export、extends、fimal、float、goto、implements、import、int、interface、long、mative、package、private、protected、public、short、static、super、synchronized、throws、transient、volatile 等。

js的关键字有很多啊

break delete function return typeof

case do if switch var

catch else in this void

continue false instanceof throw while

debugger finally new true with

default for null try

详细出处参考:http://www.jb51.net/article/13015.htm