I want to fly Higher!
天行健 君子以自强不息.I CAN PLAY!

<script>
1当selection为null或者undefined,selection || []的值为[];

  var selection=undefined;//selection=null;
  alert((selection || []).length);


2

 function isFavorite(id) {
   var byId ={"57bf4b85-5ae6-45ac-a909-ce0c4cd88959":1, "ab23d1d4-360d-4945-ba30-44dedb6a3bcc":1,"ab23d1d4-360d-   4945-ba30-44dedb6a3bcc2":1};
      if (byId)
      //!!一般用来将后面的表达式转换为布尔型的数据(boolean)
         return !!byId[id];//byId[id]:根据属性获取值
      return undefined;
  }
alert(isFavorite("ab23d1d4-360d-4945-ba30-44dedb6a3bcc2"));
</script>

posted on 2014-02-24 17:00  今晚打老虎&  阅读(254)  评论(0)    收藏  举报