標籤:php null def 學習 index let .sh fine htm
1、確定類型才能進行操作
var message=‘‘message==false (返回true)undefined==null (返回true) 2、其它類型如何轉為資料型Number(‘‘) =>0Number(‘123‘)=>123Number(‘123php‘)=>NaNparseInt(‘123php‘)=>123parseInt(‘12.3‘)=>12parseFloat(‘12.3php‘)=>12.3
3、JavaScript中的字元方法var str=‘php中文網‘str.charAt(3)=>中str.indexOf(‘p‘)=>0str.lastIndexOf(‘p‘)=>2str.substr(3,3)=>中文網 (從第幾個開始,取多少個字元)str.substring(3,str.length)=>中文網 (從第幾個開始,取到第幾位-1)str.replace(‘php‘,‘js‘)=>js中文網 var url=‘www.top789.cn‘url.split(‘.‘)=>[‘www‘,‘top789‘,‘cn‘]url.toUpperCase()=>WWW.TOP789.CNurl.toLowerCase()=>www.top789.cn
(1)var arr=new Array();arr[0]=‘abc‘arr[1]=‘def‘(2)var lang=[‘html‘,‘js‘,‘css‘]lang.length=>3lang.push(‘jquery‘,‘bootstrp‘)=>數組尾部添加lang.unshift(‘前端‘,‘開發‘)=》數組頭部添加lang.pop()=>刪除最後一個lang.shift()=>刪除第一個delete lang[1]=》 刪除清空資料,得到undefined,但位置還在lang.splice(1,2,‘php‘,‘java‘)=>["html", "php", "java"]splice() 方法向/從數組中添加/刪除項目,然後返回被刪除的項目。
javascript學習筆記