每日3题(48)

2020/4/25

HTTP:什么是无状态协议,HTTP 是无状态协议吗,怎么解决

CSS: 用纯CSS创建一个三角形的原理是什么?

JavaScript:来几道基础题

HTTP:什么是无状态协议,HTTP 是无状态协议吗,怎么解决

很形象的表示

CSS: 用纯CSS创建一个三角形的原理是什么?

<style>
div{
  width: 0;
  /*控制整体大小*/  
  border: 100px solid;  
  border-color: transparent transparent blueviolet transparent;
  /*可有可无,可以调节高度*/
  border-width: 100px 100px 100px 100px;
}
</style>
<div></div>

JavaScript:来几道基础题

题目来源

题号与原文题号对应

// 1.输出是什么?
function sayHi() {
  console.log(name)
  console.log(age)
  var name = 'Lydia'
  let age = 21
}
sayHi()

// 2.输出是什么?
for (var i = 0; i < 3; i++) {
  setTimeout(() => console.log(i), 1)
}

for (let i = 0; i < 3; i++) {
  setTimeout(() => console.log(i), 1)
}

// 3.输出是什么?
const shape = {
  radius: 10,
  diameter() {
    return this.radius * 2
  },
  perimeter: () => 2 * Math.PI * this.radius
}

shape.diameter()
shape.perimeter()

// 4.输出是什么?
+true;
!"Lydia";

// 5.哪一个是正确的?
const bird = {
  size: 'small'
}

const mouse = {
  name: 'Mickey',
  small: true
}

A: mouse.bird.size是无效的
B: mouse[bird.size]是无效的
C: mouse[bird["size"]]是无效的
D: 以上三个选项都是有效的

// 7. 输出是什么?
let a = 3
let b = new Number(3)
let c = 3

console.log(a == b)
console.log(a === b)
console.log(b === c)

// 8. 输出是什么?(做错)
class Chameleon {
  static colorChange(newColor) {
    this.newColor = newColor
    return this.newColor
  }

  constructor({ newColor = 'green' } = {}) {
    this.newColor = newColor
  }
}

const freddie = new Chameleon({ newColor: 'purple' })
freddie.colorChange('orange')

A: orange
B: purple
C: green
D: TypeError

//答案: D
//colorChange 是一个静态方法。静态方法被设计为只能被创建它们的构造器使用(也就是 Chameleon),并且不能传递给实例。因为 freddie 是一个实例,静态方法不能被实例使用,因此抛出了 TypeError 错误。

// 9. 输出是什么?
let greeting
greetign = {} // Typo!
console.log(greetign)

猜你喜欢

转载自blog.csdn.net/weixin_44194732/article/details/105744369