?????? ??? ??
JavaScript? ??? ??
JavaScript?? ?? ??? ?? 6?? ??? ??? ????.
??? ?? ????????????????????????????????> com", 'string' ?? ? ?? ??? ??? ??? ?? ??(???? ??? ?? ?? ?? ???? ??) 30, -10, 11.2, 2.35e10 ??? ??? true ?? false? ? ?? ??? ?????. 5 = = 2 ?? ??? false
Null ? ?? ?? ?? ?? ?? ????(null). ??? null ?? ???? ??? ??? ?? ? ????. str = null
Undefine type ??? ??? ? , ??? ?? ???? ?????. ? ???? ??? ?? ????: undefine var str
?? ?? ??? ?? ?? ?? JavaScript? ???? ?? document.getElementById("article")
??? ??
??? ??? ???? " ?? ????? '? ?? ????. ??? ? ?? ????.
<!DOCTYPE html> <html> <head> <meta charset="utf-8"> <title>php中文網(wǎng)(php.cn)</title> <script type="text/javascript"> var str1 = '20 '; var str2 = '歲'; alert( str1 + str2 ); </script> </head> <body> </body> </html>
? ???? ?? + ??? ???? ???? ??? ? ????. ?? ????, ???? ??? ???? ??? ?????:
20?
??: ??? ??? ??? JavaScript?? ??? ??? ?? ??? ? ????
?? ??
?? ???? ??? ?? ?? ? ?? ??? ??(???? ??? ?? ?? ??? ???? ??)? ?????.
<!DOCTYPE html> <html> <head> <meta charset="utf-8"> <title>php中文網(wǎng)(php.cn)</title> <script type="text/javascript"> var num1 = 20; var num2 = 33.5; alert( num1 + num2 ); </script> </head> <body> </body> </html>
? ?? ???? ???? ??? ???? ?????. ?? ??? ??? ????. 53.5
??? ??? ?? ??? + ??? ?? ???? ?? ?? ???? ???? ??? ???? ??? ?????. ??? ?? ???? num1? num2? ???? ?? ()? ??? ?? ????? ????.Boolean ??
Boolean ??? ???? true?? ??? true??, ??? ??? false???. ????? ?? ?? ?? if ?? ???? ??? ??? ????.
<!DOCTYPE html> <html> <head> <meta charset="utf-8"> <title>php中文網(wǎng)(php.cn)</title> <script type="text/javascript"> var x = 3; var y = 5; if( x == y ){ alert( "x 等于 y"); }else{ alert( "x 不等于 y" ); } </script> </head> <body> </body> </html>
Null(Null)
Null ? ??? ??? ??? ?? ??? ?????. ?? ??, ?? ??? ?? ??? ??? ?? ? JavaScript? ???? ??? ?? ?? ??? ?? ???? ?? ??? null???.
null ??? ????? ??? ??? null? ???? ???.
if( x == null ) { ... }
? ??? ?? ??? ???? , ?? ? ?? ??? ???? ??? ??? null ?? ???? ??? ??? ?? ? ????.
???? ?? ??
??? ??? ? ??? ??? ?? ??? ?? ??? ???? ?? ?????. ???? ?? ??? ?? ?? ???? ????? ?? ?? ?? ??? ???? ?? ???? ????? ???? ?? ??? ???? ???.
if( x == undefine ) { ... }
Object type
?? ??? JavaScript?? ????? ???? ?????. ?? ?? document.getElementById()? ?? ??? ??? ??? ? ?? ?? ?????.
<!DOCTYPE html> <html> <head> <meta charset="utf-8"> <title>php中文網(wǎng)(php.cn)</title> <script language="JavaScript"> x = document.getElementById("article"); alert(x); </script> </head> <body> <p id="article">我是一些文字 ...</p> </body> </html>
?? ?? ??
? ??? ??? ? "new" ???? ???? ?? ??? ??? ? ????.
var carname=new String;
var x= new Number;
var y= new Boolean ;
var ???= ? ??;
var ??= ? ??;