您好,欢迎访问三七文档
当前位置:首页 > 商业/管理/HR > 公司方案 > 02 数据类型、常量与变量
2ValueJavaScriptLiteralVariableDataType2.1JavaScript332.1.1JavaScriptUnicodeJavaScriptchar12.1.2JavaScriptJavaScriptJavaScript1030810308JavaScript❑InfinityJavaScriptJavaScriptJavaScriptInfinityJavaScriptJavaScriptJavaScriptInfinity❑NaNJavaScriptNaNNotaNumberJavaScriptNaN00JavaScriptNaNNaNNaNJavaScriptisNaN()NaNInfinityNaNJavaScriptNumber❑Number.MAX_VALUEJavaScript1.7976931348623157e+308❑Number.MIN_VALUEJavaScript05e324❑Number.NaN252❑Number.POSITIVE_INFINITYInfinity❑Number.NEGATIVE_INFINITYInfinity2.1.3truefalsex2x2truex2false2.2JavaScript2.2.1Linktextlink.textJavaScriptWindowalertwindow.alert(message)2.2.2JavaScript0abc13abc[0]abc[1]2.3JavaScriptNullUndefined32.3.1FunctionJavaScriptJavaScript0JavaScript26JavaScriptJavaScriptisNaN()Math.sqrt()varbFlag=isNaN(0/0);varx=Math.sqrt(100);1true210JavaScriptJavaScriptfunctionmysum(x,y){returnx+y;}JavaScriptvara=mysum(2,13)2.3.2nullnull000nullJavaScriptNULLNullnull2.3.3undefinedundefinedJavaScriptundefined2.4JavaScript2.4.1JavaScriptNotypeJavaScriptJavaScriptJavaScriptJavaScriptJavaScriptJavaScriptif(1)272{document.write(ok);}1true10JavaScripttruedocument.write(true);write()JavaScripttruetrueJavaScript❑true0false❑123123NaNabcNaNtrue❑0false❑true1true❑false0false❑nullnull0false❑NaNNaNfalse❑undefinedundefinedNaNfalse❑truetrue1❑falsefalse02.4.2JavaScript1.JavaScripttoString()vararr=[JavaScript,VBScript,Script];document.write(arr.toString());JavaScript,VBScript,ScriptDateErrorNumberFunctiontoString()28JavaScript2.JavaScriptNumber()Boolean()String()vars=1vari=Number(s)+2;document.write(i);3Number(s)11Boolean()String()Number()Number()Boolean()String()31vars=123+;varstr=+123;20vars=123;varsa=s-0;3!vars=true;if(!!s){document.write(s)}vari=1;if(!!i){document.write(i)}2.5LiteralsJavaScript5JavaScript2.5.1JavaScriptJavaScriptJavaScript310900012397836492922007034501270730x0X09afAF0x1230X1340x12ff0xffJavaScripta=a+123b=4*7JavaScript2.5.21301.223344.283.223232312eE31.2e31E43.5e-26.112E-3eE10eE1.2e3=1.2103=12001E4=1104=100003.5e-2=3.510-2=0.0356.112E-3=6.11210-3=0.0061122.5.3'030JavaScriptJavaScriptJavaScript'JavaScript'JavaScript'slanguage'aabb'2.5.4JavaScript'JavaScriptJavaScriptJavaScript'JavaScript''JavaScript'\\'\JavaScript\'\'JavaScript\''JavaScript'\'JavaScript\'\'JavaScript\'\JavaScript2.12.1JavaScript\0NULL\f\b\r\t\\n\'\v\\htmlheadtitle/titlescriptlanguage=javascripttype=text/javascript312!--document.write(JavaScript\'\br);document.write(c:\\winnt\\system32);alert(\nHTML\nJavaScript);--/script/headbody/body/html\02\sample01.htm2.1\''\\\\\n2.1sample01.htm2.5.5truefalseJavaScript01falsetrue2.5.6JavaScript=[1,2,3]❑❑01[]htmlheadtitle/title32JavaScriptscriptlanguage=javascripttype=text/javascript!--arr=[JavaScript,2,true];document.write(arr[0]+br);document.write(arr[1]+br);document.write(arr[2]+br);--/script/headbody/body/html\02\sample02.htm2.2htmlheadtitle/titlescriptlanguage=javascripttype=text/javascript!--arr=[JavaScript,,true,];document.write(arr[0]+br);document.write(arr[1]+br);document.write(arr[2]+br);document.write(arr[3]+br);--/script/headbody/body/html\02\sample03.htm2.34arr[0]JavaScriptarr[1]arr[3]undefinedarr[2]true2.2sample02.htm2.3sample03.htm3322.6VariableIdentifier2.6.1JavaScriptASCII_1xX_xx_1JavaScriptxXJava❑dateabc❑datetheDateotherDate❑JavaScript2.6.2JavaScriptJavaScriptNotypeJavaScriptJavaScriptx=abc;x=101;2.6.3JavaScript34JavaScriptJavaScriptvarvarx;varX;var_x;varx_1;varvarx,X,_x,x_1;undefinedJavaScriptvarx=abc;varn=null;varbFlag=true;vartheDate=2007-6-20,i=100;2.6.4JavaScript1.JavaScripthtmlheadtitle/titlescriptlanguage=javascripttype=text/javascript!--varx=1;document.write(x+br);varx=test;document.write(x);--/script/headbody/body/html\02\sample04.htm2.4x2.JavaScript3522.4sample04.htmhtmlheadtitle/titlescriptlanguage=javascripttype=text/javascript!--document.write(x);--/script/headbody/body/html\02\sample05.htmxdocument.write()x2.52.5sample05.htm3.JavaScriptJavaScriptJavaScripthtmlheadtitle/titlescriptlanguage=javascripttype=text/javascript!--x=;document.write(x);--/script/headbody/body/html\02\sample06.htmvar36JavaScriptxx2.64.undefinedhtmlheadtitle/titlescriptlanguage=javascripttype=text/javascript!--varx;document.write(x);--/script/headbody/body/html\02\sample07.htmxxxundefined2.72.6.5JavaScript❑Number12312.3❑Logicaltruefalse❑String❑Null❑Undefined2.6.6GlobalJavaScriptLocalhtml3722.6sample06.htm2.7sample07.htmheadtitle/titlescriptlanguage=javascripttype=text/javascript!--//xvarx=;//functionlinkClick(){//alert(x);}--/script/headbody!----ahref=javascript:linkClick()/ascriptlanguage=javascripttype=text/javascript!--//document.write(x);--/script/body/html\02\sample08.htm2.81xx2linkClickxx3linkClick()x4JavaScriptxheadJavaScriptxhtmlheadtitle/titlescriptlanguage=javascripttype=text/javascript!--38JavaScript2.8sample08.htm//functionlinkClick(){//
本文标题:02 数据类型、常量与变量
链接地址:https://www.777doc.com/doc-6370070 .html