资源描述:
《javascript常用函数集(常规函数、数组函数、日期函数、数学函数、字符串函数)》由会员上传分享,免费在线阅读,更多相关内容在工程资料-天天文库。
1、javascript常用函数集(常规函数.数组函数、日期函数、数学函数、字符串函数)JavaScriptprovidesmanyfunctionsfordeveloperstouse,andhereisabriefintroduction,moredetailedinformation,refertotheonlinehelpprovidedbyVisualIntcrDcv.JavaScriptfunctionscanbedividedintofivecategories:conventionalfunctions,arrayfunctions,datefunct
2、ions,mathematicalfunctions,stringfunctions・1,regularfunctionTheJavaScriptroutinefunctionconsistsofthefollowing9functions:(1)alertfunction:displaysawarningdialogbox,includingaOKbutton.(2)confirmfunction:displaysaconfirmationdialog,includingtheOKandCancelbuttons・(3)escapefunction:conver
3、tscharactersintoUnicodccodes・(4)Evalfunction:calculatingtheresultofanexpression.(5)isNaNfunction:thetestis(true),no(false)isnotanumber・(6)parseFloatfunction:convertsstringsintocharacternumbers・(1)parselntfunction:convertsstringsintointegernumbers(whichcanbespecifiedinhexadecimalnumber
4、s)・(2)promptfunction:displaysaninputdialogboxthatpromptsforuserinput・Suchas:Script>(3)theunescapefunctiondecodesthecharactersencodedbytheescapefunction.1,arrayfunctionTheJavaScript
5、arrayfunctionconsistsofthefollowing4functions:(1)joinfunction:convertandcormectallelementsinanarraytoastring.Cases:Function,JoinDemo()VaR,a,b;A二new,Array(0,1,2,3,4);B=a・join(〃-“);//delimiterReturn(b);//returnb=0-1-2-3-4〃}Cases:(1)lengthfunction:returnsthelengthofthearray.Function,Leng
6、thDemo(){VaR,a,1;A二new,Array(0,1,2,3,4):L二a・length;Return(L);//1=5(2)reversefunction:invertthearrayelementsinreverseorder・Cases:Function,ReverseDemo(){VaR,a,1;A二new,Array(0,1,2,3,4);L=a・reverse();Return(L);}(1)sortfunction:reorderthearrayelements・Cases:Function,SortDemo(){VaR,a,1;A二ne
7、w,Array(〃X〃,〃Y〃,〃d〃,,〃厂,〃nT,〃R〃);L=a.sort();Return(L);1,datefunctionTheJavaScriptdatefunctionconsistsofthefollowing20functions:(1)getDatefunction:thedatevalueofthereturndate,whichis1'31.Cases:Function,DateDemo(){VaR,D,s二"Today's,date,is:〃〃;D二new,Date();S二(d.getMonth)(+1)+〃/〃;S二d.getDa
8、te(+)