javascriptebi A,N,R,I 29 სექტ 2013, 21:32 daprogramebis ena JavaScript JavaScript-i daprogramebis ena gamoiyeneba HTML dokumen- tebis Sesaqmnelad. enis mTavari aspeqti aris obieqtis cneba. literalebi literalebi literalebi literalebi martivi monacemebi razedac SeiZleba agebuli iqnas prog- rama aris literalebi. mTeli tipis mudmivebi SeiZleba moce- muli iqnas aTobiTi TeqvsmetobiTi, an rvaobiTi formiT. mTeli tipis aTobiTi mudmivebi SeiZleba warmodgenili iyos niSniT an niSnis gareSe magaliTad 15,125, -156 +3546. TeqvsmetobiTi ricxvebi Seicaven cifrebs 0-9-mde da asoebs a,b, c, d. e,f. TeqvsmetobiTi ricxvebi iwereba ricxvis win simboloTi 0x, magaliTad 0x25, 0xa1, 0xff. rvaobiTi ricxvebi Seicaven mxolod cifrebs 0-dan 7-is CaTvliT daiwereba ase 03, 0543. 011. aTwiladi ricxvebis Casawerad, rogorc yvela daprogra- mebis enaSi mZimis nacvlad gamoiyeneba wertili. magaliTad, 123. 45, -56.789. aTwiladi ricxvebis Casawerad gamoiyeneba eqsponencialu- ri forma magaliTad, ricxvi 0,000000234 romelic SeiZleba ase warmovadginoT 2.34x10-7 JavaScript daprogramebis enaze Caiwereba 2.34e-7. aTobiTi da mTeli mudmivebis garda arsebobs logikuri mudmivebi, romlebic iReben mxolod or mniSvnelobas WeSmari- ti – true zogierT warmodgenaSi - 1, mcdari- false – 0. striqonuli literali warmoadgens simboloebis Tanmim- devrobas romelic moTavsebulia ‘ ‘ an “ “ simboloebSi. magaliTad “ Sedegi” an ’Sedegi’. carieli striqonuli cvladi aRiniSneba ‘ ‘ an “ ” simboloebiT. cvladi cvladi cvladi cvladi cvladebi gamoiyeneba monacemebis Sesanaxad. cvladebis aRwera xdeba identifikatoris saSualebiT. identifikatori aucileblad unda iwyebodes laTinuri alfavitis asoTi an gaxazvis simboloTi , Semdeg SeiZleba Cawerili iyos cifri an gaxazvis simbolo. magaliTad test1, _my-test, test-1. cvladis tipi ganisazRvreba maTSi Senaxuli monacemebis tipiT, monacemebis tipis SecvliT icvleba cvladis tipi. cvladis gansazRvra xdeba sityviT var is aucileblad unda iyos gamoyenebuli cvladebis aRwerisas an inicializaciisas. magaliTad, var t1. aq cvladis tipi ar aris gansazRvruli da is cnobili gaxdeba mas Semeg rac mas mieniWeba mniSvneloba es ki xdeba miniWebis operatoris saSualebiT. magaliTad: var t1=345 am SemTxvevaSi t1 cvlads miniWebuli aqvs mniSvneloba 345. cvladis mniSvneloba SeiZleba Seicvalos aseve miniWebis operatoriT. miniWebis operatori SeiZleba gamoyenebuli iyos nebismier adgilze da SeuZlia Secvalos ara marto monacemi aramed cvladis tipic. miniWebis operators aqvs saxe: a=b sadac a- cvladia, b- gamosaxuleba. dasaSvebia cvladebis Semdebi aRwera: var n=3245 var x=2.89 var p=true var s=”gamoTvla damTavrebulia” n da x cvladebs aqvT ricxviTi tipi, p-s aqvs logikuri tipi, xolo s-s string. JavaScript-Si gansazRvrulia aseve function tipi yvela standartuli funqciisaTvis da aseve momxmareblis mier gansazRvruli funqciebisaTvis. JavaScript-Si obieqtebs aqvT monacemTa tipi object. cvladebis moqmedebis are cvladebis moqmedebis are cvladebis moqmedebis are cvladebis moqmedebis are JavaScript-Si arsebobs ori tipis cvladebi globaluri da lokaluri. globaluri cvladi gansazRvrulia mTel programaSi, lokaluri cvladi gansazRvrulia mxolod konkretuli funqciis SigniT. gamosaxuleba gamosaxuleba gamosaxuleba gamosaxuleba gamosaxuleba Sedgeba literalebisagan, cvladebisagan, moqmedebaTa niSnebisagan da frCxilebisagan. gamosaxulebis gamoTvlis Semdeg miiReba erTi mniSvneloba, romelic SeiZ- leba iyos ricxvi, striqoni, an logikuri. gamosaxulebaSi arsebul yvela cvladi unda iyos gan- sazRvruli. Tu gamosaxulebaSi arsebul romelime cvlads ar aqvs mniSvneloba an ar aris gansazRvruli maSin xdeba Secdomis dafiqsireba. JavaScript-Si arsebobs null literali romelic aRniSnavs ganusazRvrel mniSvnelobas. nebismieri gamosaxuleba Sedgeba operandebis da opera- ciis niSnebisagan. magaliTad, gamosaxuleba a*b -Si, a da b operandebia, * operaciis niSania. operaciebi arseboben unaruli (erTadgiliani) da bina- ruli (oradgiliani). gamosaxuleba Caiwereba +A, Tu + - unaru- li operaciis aRniSvnaa, an A+B. Tu + - binaruli operaciis aRniSvnaa. gamoTvlili mniSvnelobis mixedviT, gamosaxuleba SeiZ- leba arsebobdes ariTmetikuli, logikuri da striqonuli. ariTmetikuli gamosaxulebis Casawerad gamoiyeneba Sem- degi operatorebi: + Sekreba - gamokleba * gamravleba / gayofa % naSTis miReba gayofis Sedegad ++ operandis mniSvnelobis gazrda 1-iT -- operandis mniSvnelobis Semcireba1-iT operaciebis Sesruleba xdeba marcxnidan marjvniv ariT- metikuli operaciebis prioritetis mixedviT. JavaScrip-Si gamoiyeneba operatorebis Caweris Semoklebu- li forma: X+=Y X=X+Y X-=Y X=X-Y X*=Y X=X*Y X/=Y X=X/Y X%=Y X=X%Y JavaScript-Si gamoiyeneba Sedarebis Semdegi operaciebi. isi- ni Sesrulebis Sedegad iReben mxolod or mniSvnelobas true Tu Sedareba WeSmaritia an false winaaRmdeg SemTxvevaSi. es operaciebia: < naklebia <= naklebia an tolia == tolia != ar aris toli > metia >= metia an tolia ! operacia (logikuri ara) gamoiyeneba logikuri tipis operandebze. Tu a operandis mniSvneloba true, maSin !a – mniS- vneloba aris mcdari, Tu a operandis mniSvneloba aris false , maSin !a - mniSvneloba aris WeSmariti. garda aRniSnulisa logikuri operaciebis Sesasruleblad gamoiyeneba Semdegi logikuri operaciebi: && (logikuri da), || (logikuri an) maTi Sesrulebis Sedegi moyvanilia cxrilSi A B A&&B A||B true true true true true false false true false true false true false false false false striqonul mniSvnelobebze dasaSvebia konkatenciis (Seer- Tebis) operacia. is aRiniSneba + niSniT. magaliTad, st1= “mimdinare” st2=”mdgomareoba” st3=st1+st2 an st1+=st2 maSin st3 miiRebs mniSvnelobas “mimdinare mdgomareoba” st1-ic miiRebs mniSvnelobas “mimdinare mdgomareoba” JavaScript-Si gamoiyeneba Semdegi operatorebi (isini mocemulia prioritetis Semcirebis mixedviT): inkrementi ++ dekrementi -- uaryofa ! unaruli minusi - gamravleba * gayofa, gayofa naSTis SenaxviT /,% gamokleba - Sedareba <,>,<=,>= toloba == ar aris toli != logikuri da && logikuri an || miniWeba +, +=, -=, *=, /=, %=, != monacemTa tipebis gardaqmna monacemTa tipebis gardaqmna monacemTa tipebis gardaqmna monacemTa tipebis gardaqmna monacemTa tipebi gavlenas axdens operatorebis Ses- rulebaze, gansakuTrebiT maSin Tu operandebs aqvT sxvadasxva tipi. aviRoT magaliTad ori ricxvis Sekrebis magaliTi 3+3 Sedegi iqneba 6, magram roca operandebs sxvadasxva tipi aqvT 3+”3” Sedegi iqneba”33” radgan meore operandis tipi aris striqonuli e.i Sedegi iqne- ba striqonuli tipis. pirveli operandi avtomaturad gardaiqm- neba striqonul tipad da Sedegad miiReba ori striqonis gaerTianeba. Tu adgili eqneba aseT SemTxvevas: 3+3+”3” maSin Sedegi iqneba “63”. JavaSkript enas aqvs SesaZlebloba striqonuli simboloebi gardaqmnas ricxviT monacemebad. amisaTvis iyenebs funqciebs: parselnt () da ParseFloat(). magaliTad: parseInt (“34”) Sedegi iqneba 34 parseInt (“23.56”) Sedegi iqneba 23 e. i meore SemTxvevaSi Sedegis damrgvaleba moxdeba mTelamde. ParseFloat(“42”) Sedegi iqneba 42 ParseFloat(“42.56”) Sedegi iqneba 42.33 rom gamoviyenoT es funqciebi iq sadac saWiroa gardaqmna unda CavsvaT Sesabamisi funqcia. magaliTad: 3+3+ parseInt”3” Sedegi iqneba 9. ricxviTi mniSvnelobis gardavqmna striqonulad ganvixiloT martiv magaliTebze: (“”+2500) Sedegi iqneba2500 (“”+2500). length Sedegi iqneba 4. length niSnavs rom daTvlili iqneba simboloebis raodenoba. magaliTad, “2500” simboloebis raodenoba masSi tolia 4-is. length - sigrZe , misi tipi aris ricxvi da striqoni. HTML dokumentSi programis Casma dokumentSi programis Casma dokumentSi programis Casma dokumentSi programis Casma JavaScript-ze dawerili programa SeiZleba moTavsdes HTML dokumentSi tegebs Soris, Tu romelime tegi gamorCenili iqneba programa ar gaiSveba. SevadginoT marTkuTxa samkuTxedis farTobis gamosaTvle- li programa, roca mocemulia misi kaTetebi pirveli programa

programa

programis dasasruli

PprogramaSi gamoyenebulia ori cvladi a da b. HTML gverdze gamotanis formirebisaTvis gamoiyeneba write document obieqtSi Tu JavaScript- s mxars ar uWers brauzeri, maSin gamoiyeneba tegi