首页 > ActionScript 3, flex > ActionScript 3中===与==及!==与!=操作符的区别

ActionScript 3中===与==及!==与!=操作符的区别

===与==操作符的区别如下:
1.全然(strict)相等的比较操作符(===)的操作只对数字类型变量的惊醒数据类型转换,
而一般相等的比较操作符(==)的操作符对所有基本数据类型进行转换。
2.使用===相等比较符来比较null和undefined,它总是返回flase(不成立)。
!==与!=操作符的区别如下:

1.全然(strict)不相等的比较操作符(!==)的操作只对数字类型变量的惊醒数据类型转换,
而一般不相等的比较操作符(!=)的操作符对所有基本数据类型进行转换。
2.使用!==相等比较符来比较null和undefined,它总是返回true(成立)。

例子源码
注意编译的时候用: xmlc -strict=false StrictComparison1.mxml
或者如果直接在flex 3编译器里 右键项目属性 Flex Compiler里增加-strict=false后 -locale en_US -strict=false

xmlns:mx="http://www.adobe.com/2006/mxml"
viewSourceURL=""
horizontalAlign="center" verticalAlign="middle"
width="100%" height="100%"
>

private function showProperties():void {
var a1:String = "5";
var a2:String = new String("5");
var b1:int = 5;
var b2:Number = new Number(5);

var result:Boolean;
result = a1 == a2; //result is true;
panelPropertyArea.text = "result: " + result + "\n";
result = a1 === a2; //result is true;
panelPropertyArea.text += "result: " + result + "\n";
result = a1 == b1; // result is true
panelPropertyArea.text += "result: " + result + "\n";
result = a1 == b2; // result is true
panelPropertyArea.text += "result: " + result + "\n";
result = a1 === b1; // result is false
panelPropertyArea.text += "result: " + result + "\n";
result = a1 !== b1; // result is false
panelPropertyArea.text += "result: " + result + "\n";
result = a1 === b2; // result is false
panelPropertyArea.text += "result: " + result + "\n";
result = b1 == b2; // result is true
panelPropertyArea.text += "result: " + result + "\n";
result = b1 === b2; // result is true
panelPropertyArea.text += "result: " + result + "\n";

panelPropertyArea.text += "+++++++++++++++++++++++++\n";
result = a1 != b1; // result is false
panelPropertyArea.text += "result: " + result + "\n";
result = a1 !== b1; // result is true
panelPropertyArea.text += "result: " + result + "\n";
result = a2 != b1; // result is false
panelPropertyArea.text += "result: " + result + "\n";
result = a2 !== b1; // result is true
panelPropertyArea.text += "result: " + result + "\n";

panelPropertyArea.text += "+++++++++++++++++++++++++\n";
result = null == null; // result is true
panelPropertyArea.text += "result: " + result + "\n";
result = null === null; // result is true
panelPropertyArea.text += "result: " + result + "\n";
result = null == undefined; // result is true
panelPropertyArea.text += "result: " + result + "\n";
result = null === undefined; // result is false
panelPropertyArea.text += "result: " + result + "\n";
}
]]>

height="75%" width="75%"
paddingTop="5" paddingLeft="5" paddingRight="5" paddingBottom="5">
text="Program Execution Result: "/>



说明本文章是我自己来自<>读书笔记,

原创文章转载请注明出处:云飞扬IT的blog

本文链接: http://www.ajaxcn.net/archives/278

一键分享到:新浪微博分享  分享到网易微博    转贴到开心网  推荐到豆瓣  分享到QQ空间    RSS订阅
  1. 本文目前尚无任何评论.
  1. 本文目前尚无任何 trackbacks 和 pingbacks.

key office 2010

office 2010 key

corel dvd moviefactory 6

corel dvd moviefactory 6 downloads

serial corel draw 11

serial corel draw 11 serials

windows 7 key

windows 7 key

office 2010 professional key

office 2010 key

windows key

windows key

free winrar download for xp

download winrar for xp for free

winrar password cracker serial

wirar password cracker

cs5 serialz

cs5 serialz free

photoshop key

photoshop key

free corel photoshop download

free corel photoshop download keygen

photo shop key

photo shop key

download photo shop free

photo shop serial

serial winzip 11

serial winzip 11 key

adobe free

adobe free

windows 7 free

windows 7 crack

winrar 3 download

winrar 3 download freedownload

office 2010 free

office 2010 key

free corel downloads

free corel downloads cracked