• Blogs (9)
    • 📱 236 - 992 - 3846

      📧 jxjwilliam@gmail.com

    • Version: ‍🚀 1.1.0
  • JavaScript: some testings

    Blogs20132013-06-28


    JavaScript: some testings

    Some of my testings of JavaScript, interesting and keep for retrieving:

    function a1() { return; }
    function a2() { return false; }
    t=a1(); console.log(t===undefined); //true
    t=a2(); console.log(t===false)		//true
    
    //Keep in mind that the target object (first argument) will be modified,
    //and will also be returned from $.extend()
    var info = { user: function(){}, pass: function(){} };
    var t1 = $.extend({}, info, { type: "change", val: 123 });
    
    var t2 = {};
    $.extend(t2, info, { type: "change", val: 123 });
    t1 == t2   //false
    console.log(t1); //t1 and t2 are same, but not equal.
    console.log(t2);

    Here is a whole version of how to receive parameters from a event:

    //1.HTML:
    <input id='input_id' />
    ...
    
    //2. JS parameters and calling:
    
    var obj = {
      user: getUser(),
      pass: $.pass(),
      data: [],
      o :   {..},
      Id:  123
    }
    $('#input_id').one('click', obj, getFullList);
    
    //3. function to process:
    // The following params will accept parameters from 'click' event:
    function getFullList(e) {
        var params = e.data;
        $.extend(defaults, params);
    ...
    }

    This is the way of ‘event’ pass parameters.