//JS Case sensitive note ' and; //single-line comment /*Multi-line comments*/ //JS Output Syntax //alert (' Sunday '); //console.log (' Sunday ') Console output //var aa = prompt (' Please enter your name '); the input is a string and the operation is to be converted into a numeric value. text Box //document.write (' 123 '); Web input //Digital Type: number //var AA = assigned value varnumb = 123; varStr= "123"; //alert (' typeof number '); //conversion of numeric types //Turn Digital Type //Number (str); //Alert (typeof number (str)); //parseint (); Integer Turn //parsefloat (); There are decimals //Turn characters //String (); //toString (); //alert (typeof numb.tostring ()); //Example: varA = 12; varb = "10"; //alert (a+b); //alert (A+number (b)); //alert (A+parseint (b)); //operator //+ - * / % //addition //1 Normal addition varc = 1; varD = 2; varE = c +D; //alert (e); //2 concatenation of strings varf = "Hello"; varg = "World"; varh = f +G; //alert (h); //3 value to string vari = 1; varj = "2"; varK = i +J; //alert (typeof K); //Subtraction //subtraction of 1 values varL = d-C; //alert (L) //2 Take negative numbers //3 String to value varm = J-i; //alert (typeof m); //multiplication //multiplication of numerical values //Division //Division of numeric values //Take surplus //var n = +; //var o = 3; //var p = n% o; //alert (p); //compound operator: + = = *=/=%= //var q = n; //q +=5; //equivalent to q = q + 5; //alert (q); //q-=5; //equivalent to q=q-5; //alert (q); //q*=3; //equivalent to q=q*3; //alert (q); //q/= 2; //equivalent to Q=Q/2; //alert (q); //q%=5; //equivalent to q=q%5; //alert (q); //self-increment to decrement: + +-- //var r = N; //var s = r++; //Step one var s = r; //Step Two r = r+1; //alert (s); //var s = ++r; //Step one r= r+1; //Step two var s = r; //alert (s); //var s = r--; //Step one var s = r; //Step two r=r-1; //alert (s); //var s =--r; //Step one r=r-1; //Step two var s = r; //alert (s); //var aa = new Array ();alert (AA);
JS Basic Knowledge Introduction