一些小题目


一些小题目_第1张图片

因为清明节的缘故,本周要上六天班,我的心情如下图!

一些小题目_第2张图片


先来个晨读例句,与君共勉。

We're born alone, we live alone, we die alone. Only through our love and friendship can we create the illusion for the moment that we're not alone. 


任务都完成得差不多了,偷会闲,看了一些js的题

  function say(msg, name, method) {
    console.log(msg);
    console.log(name);
    console.log(method);
    var msg,
      name = 'tom';
    function method() {
    }
  }
  say('hello');

运行结果如下:

hello
undefined
function method() {
    }



  (function() {
    var a = b = 3;

  })();
  console.log("a defined?" + (typeof a !== 'undefined'));
  console.log("b defined?" + (typeof b !== 'undefined'));

运行结果如下:

a defined?false

b defined?true




  var myObject = {
    foo: "bar",
    func: function() {
      var self = this;
      console.log("outer func:this.foo=" + this.foo);
      console.log("outer func:self.foo=" + self.foo);
      (function() {
        console.log("inner func:this.foo=" + this.foo);
        console.log("inner func:this.foo=" + this.foo);
      }());
    }
  };
  myObject.func();

运行结果如下:

outer func:this.foo=bar
outer func:self.foo=bar
inner func:this.foo=undefined
inner func:this.foo=undefined




  for (var i = 0; i < 5; i++) {
    setTimeout(function() {
      console.log(i);
    }, i * 1000);
  }

运行结果如下:

5(1秒钟显示一次5)



  var a = {};
  b = {
      key: 'b'
    },
    c = {
      key: 'c'
    };
  a[b] = 123;
  a[c] = 456;
  console.log(a[b]);

运行结果:

456



  var z = 1;

  function fn() {
    console.log(z)
  }

  (function(callback) {
    var z = 2;
    callback();
  })(fn)

运行结果:

1



(后续还会补充)

你可能感兴趣的:(技术类)