美团社招一面

美团社招一面
做题
1、面试题

<style>
.outer{
	width: 100px;
	background: red;
	height: 100px;
}

.inner {
	width: 50px;
	height: 50px;
	background: green;
}

</style>
<div class="outer">
 <div class="inner"></div>
</div>

<script>
  var outer = document.querySelector('.outer');
  var inner = document.querySelector('.inner');
  new MutationObserver(function () {
    console.log('mutate');
  }).observe(outer, {
    attributes: true,
  });

  function onClick(e) {
    console.log('click');
    setTimeout(function () {
      console.log('timeout');
    }, 0);
    Promise.resolve().then(function () {
      console.log('promise');
    });
    outer.setAttribute('data-random', Math.random());
  }

  inner.addEventListener('click', onClick);
  outer.addEventListener('click', onClick);
</script>

2、js

function Foo() {
    getName = function () { console.log (1); };
    return this;
}
Foo.getName = function () { console.log (2);};
Foo.prototype.getName = function () { console.log (3);};
var getName = function () { console.log (4);};
function getName() { console.log (5);}

Foo.getName();//
getName();//
Foo().getName();//
getName();//
new Foo.getName();//
new Foo().getName();//
new new Foo().getName();//

3、
题目:
使用Vue3 / react 分别实现倒计时功能
10-0,到0时自动停止
设置3个按钮,开始 暂停 重置
解答:

注意:记得定时器使用的坑,以及取消页面挂载的时候移除定时器

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值