Variable
Variable ဆိုတာ ပါ၀င္တဲ႔အရာေတြကိုဆိုလိုတာပါ
var year;
var customerEmail;
var todaysDate;
var foo;
var x;
var 99problems; အမွား
var problems99; အမွန္
variable ကိုဖန္တီးျခင္း
var year; ဒါက undefined မလုပ္ရေသးတဲ႔ year ပါ
year = 2012 ; = နဲ႔ လုပ္ထားတဲ႔အတြက္ year တန္ဖိုးက 2012 ျဖစ္သြားပါျပီ
var year = 2012;
ေနာက္ျပီး variable name က case sensitive ျဖစ္ပါတယ္
အရင္တုန္းက Js ဟာ case sensitive ျဖစ္တယ္ဆိုတာေျပာခဲ႔ျပီးျပီ
var x= 200 ;
var X= 210;
x ျခင္းတူေပးမယ္႔ စာလံုးအၾကီးအေသးမတူတဲ႔အတြက္ေၾကာင္႔ သူရဲ႕ value ေတြလည္းမတူညီပါဘူး
Variable data types
var myVariable; //undefined variable
var myVariable= 200; //200
var myVariable= "Hell0" ; //Hell0
var myVariable= 'Hello'; //Hello
var myVariable=true; //True
var myVariable=false; //False
ကဲ႔ firefox ေလးဖြင္႔ျပီး firebug console ကိုဖြင္႔လိုက္ပါျပီးေတာ႔ ညာဖက္မွာ ေအာက္ကကုတ္ေလးကိုရိုက္ျပီး run ၾကည္႔ပါဦး
var foo=10;
var bar=20;
if(foo<bar){
alert("foo is less than bar");
alert("And here is second message");
alert("And here is third message");
}
The Output is
console ပံုစံနဲ႔ေရးၾကည္႔ရေအာင္
var foo=10;
var bar=20;
if(foo<bar){
console.log("foo is less than bar");
console.log("And here is second message");
console.log("And here is third message");
}
The Output is
ေနာက္အျခားေရးနည္း
1. console.debug
var foo=10;
var bar=20;
if(foo<bar){
console.debug("cyberoot is here");
//console.log(foo);
//console.log(bar);
}
2.console.info
var foo=10;
var bar=20;
if(foo<bar){
console.info("cyberoot is here");
//console.log(foo);
//console.log(bar);
}
3.console.warn
var foo=10;
var bar=20;
if(foo<bar){
console.warn("cyberoot.blogspot.com");
//console.log("And here is second message");
//console.log("And here is third message");
}
4.console.error
var foo=10;
var bar=20;
if(foo<bar){
console.error("cyberoot.blogspot.com");
//console.log("And here is second message");
//console.log("And here is third message");
}
ေအာက္္မွာၾကည္႔လိုက္ေနာ္ ဘယ္လိုအလုပ္လုပ္လဲဆိုတာ
No comments:
Post a Comment
Thanks for your comments
Welcome from cyberoot