2015.03.14--js value transfer and parameter transfer, deep copy of js object array, Css z-index, and writing form in omDialog will cause conflicts with omMessageBox

Today's tasks:
1. Editing and deleting in the corporate sector

Actual :
Completed

Gains :
1. The basic data type in JS is pass-by-value, but the object and array types are pass-by-reference, which may be due to operational efficiency and memory considerations, which is similar to java This strongly typed language compares like
  Example 1:
  var i = 2;
  var j = i;
  i = 3;
  alert(j); // output 3


  Example 2:
  var obj1 = {
     children:[{a:1},{a:2},{a:3}],
     id: 1,
     text: 'haha'
  };

  function test(data)
  {
      var obj2 = data;
      obj2.children = {};

      alert("obj1="obj1.children);
      alert("obj2="obj2.children);
 }
 
 alert(obj1.children)  // 输出[object][object][object]
 test(obj1); // output obj1=[object] obj2=[object]


Deep copy method:
var objectClone = function(sObj)
{
      if(typeof sObj !== "object"){       
            return sObj;       
      }       
      var s = {};   
    
      if(sObj.constructor == Array){       
          s = [];       
      }   
    
      for(var i in sObj){       
          s[i] = Object.clone(sObj[i]);       
      }       
      return s;   
}

 
2. The smaller the value of z-index in CSS, the further away from the user

3. In OMUI, try not to write form in omDialog, otherwise, when other controls (such as omMessageBox) pop up on Dialog, there will be conflicts

Guess you like

Origin http://10.200.1.11:23101/article/api/json?id=327033679&siteId=291194637