javascript學習筆記

來源:互聯網
上載者:User

標籤: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學習筆記

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.