测试

<!DOCTYPE html>
<html>
	<head>
		<meta charset="utf-8">
		<title></title>
	</head>
	<body>
		<a>a</a>
		<script>
			//数组去重
			let arr = [2,3,4,5,3,2,3,4,7,8]
			let arrAfter = Array.from(new Set(arr))
			console.log(arrAfter)
			
			//排序
			//快速排序:复杂度:nlog2n 不稳定
			var quickSort = function(arr) {
				if (arr.length <= 1) {
					return arr;
				}
				var middleIndex = Math.floor(arr.length/2)
				var middle = arr.splice(middleIndex, 1)[0];
				var left = []
				var right = []
				for (var i = 0; i < arr.length; i++){
					if (arr < middle) {
						left.push(arr[i])
					} else {
						right.push(arr[i])
					}
				}
				return quickSort(left).concat([middle], quickSort(right))
				
			}
			
			//堆栈
			
			//递归  
			
			//波兰式 逆波兰式
			
			//es数组方法
			obj.map(item => {
				//判断item
				if () {
					let arr = []
					arr.push(item))
					return arr
				}
			})
			obj.filter(item => {
				//判断条件,直接返回符合要求的
				item === a 
			})	
			
			//面向对象
			//字面量
			var o1 = {
				name: 'o1'
			}
			var o1 = new Object({
				name:'o1'
			})
			//函数
			var F = function() {
				this.name = 'o1'
			}
			var o1 = new F()
			//
			var Obj = {
				name: 'o1'
			}
			var o1 = Object.created(Obj)
			
			//new运算符
			var obj = new Object()
			obj.__proto__ = func.prototype
			var k = func.call(this)
			if (type k === 'object') {
				return k
			} else {
				return obj
			}
			//类的实例化
			function Animal() {
				this.name = 'name'
			}
			class Animal2{
				constructor() {
					this.name = name
				}
			}
			let a = new Animal()
			let b = new Animal2()
			
			//继承
			//构造函数的方式
			function Parent() {
				this.name = 'parent'
			}
			function Child() {
				Parent.call(this)
				this.sex = 'boy'
			}
			let a = new Child(); console.log(a)
			/*Child {name: "parent", sex: "boy"}
				name: "parent"
				sex: "boy"
				__proto__: Object*/
			//使用原型链继承
			function Parent() {
				this.name = 'parent'
			}
			function Child() {
				this.sex = 'boy'
			}
			Child.prototype = new Parent()
			console.log(Child.prototype)
			console.log(Parent)
				
			//组合继承
			function Parent() {
				this.name = 'parent'
			}
			function Child() {
				Parent.call(this)
				this.sex = 'boy'
			}
			Child.prototype = new Parent()
			console.log(Child.prototype)
			console.log(Parent)
			
			//组合继承的优化1
			function Parent() {
				this.name = 'parent'
			}
			function Child() {
				Parent.call(this)
				this.sex = 'boy'
			}
			Child.prototype = Parent.prototype
			
			//组合继承的优化2
			function Parent() {
				this.name = 'parent'
			}
			function Child() {
				Parent.call(this)
				this.sex = 'boy'
			}
			//创建中间对象的方法,区分开两个原型对象
			Child.prototype = Object.create(parent.prototype)
			Child.prototype.constructor = Child
			
			
		</script>
	</body>
</html>

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

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值