一些小题目


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



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

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



(后续还会补充)

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值