一套前端基础笔试题

let arr = [1, 2, 3];
let arr2 = arr1;
arr2[1] = 4;
console.log(arr);
let arr = [1, 2, 3];
let obj = {
	a: 1,
	b: arr,
	c: 3
}
obj.b[2] = 2;
console.log(arr);
let arr = [1, { a: 'a', b: 'b'}, 3];
let obj = arr[1];
obj.b = 'c';

console.log(arr);
console.log(obj);
function func() {
	console.log(num);
	var num = 1;
	console.log(num);
}

func();
function func() {
	console.log(num);
	let num = 3;
	console.log(num);
}

func();
console.log(num);
console.log(func);
var num = 3;
var func = 4;
function func() {
	console.log('hi, i am func');
}
var num = 3;

function func() {
	var num = 1;
	return function() {
		console.log(num);
	}
}
var action = func();
action();
var num = 3;

function show() {
	console.log(num);
}

function call(func) {
	var num = 1;
	func();
}

call(show);
var name = 'nacy';

var obj = {
	name: 'tom',
	age: 18,
	say: function() {
		console.log(this.name);
	}
}

let sayCopy = obj.say;
sayCopy();
function b(name, age) {
	this.name = name;
	this.age = age;
	this.say = function() {
		console.log(this.name);
	}
}

let a = new b('tom', 18);
a.say();

b.prototype.say = function() {
	console.log('hi');
}
a.say();

delete a.say;
a.say();

var obj = {
	name: 'tom',
	age: 18,
	func: {
		name: 'func',
		say: function() {
			console.log(this.name);
		}
	}
}

obj.func.say()
  1. 与new有关
function Build(name, age) {
	this.name = name;
	this.age = age;
}

let tom = new Build('tom', 18);
console.log(tom);

tom.__proto__ === Build.prototype // true
Object.prototype.toString.call(tom) // '[object Object]'

// new 的过程
// 1、创建一个空对象 obj;
// 2、将新创建的空对象的隐式原型指向其构造函数的显示原型。
// 3、执行构造函数的方法,使用 call 将 this 的指向第一步创建的obj对象
// 4、如果无返回值或者返回一个非对象值,则将 obj 返回作为新对象;如果返回值是一个新对象的话那么直接直接返回该对象
let a = {
	n: 1
}

let b = a;

a.x = a = {
	n: 2
}
console.log(a);
console.log(b);
  1. 数组方法 forEach map filter some find的作用及区别
  2. 实现js对象的遍历
  3. == 和 === 的区别
  4. 判断一个变量的类型的方法及其优缺点
  5. 浅谈时间的冒泡机制,应用的场景
  6. 什么是回流的重绘,触发的机制是什么?vue的话,v-if和v-show的区别
1. [1, 4, 3]
2. [1, 2, 2]
3. [1, {a: 'a', b: 'c'}, 3] ,  { a: 'a', b: 'c' }
4. undefined , 1
5. 报错
6. undefined, 
	func() {
		console.log('hi, i am func');
	}
7. 1
8. 3
9. nacy
10.tom, tom, hi 
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 1
    评论

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值