<h1>js基础面试题</h1> <h2>1、js 的类型</h2> 1.认识js的基本类型 > typeof undefined, //undefined typeof 'abc' ,//string typeof 123 ,//number typeof true ,//boolean typeof {} ,//object typeof [] ,//object typeof null ,//object typeof console.log ,//function typeof Symbol(1) // symbol <div>2、js 类型的原型搜索链</div> > Number.__proto__ === Function.prototype // true Boolean.__proto__ === Function.prototype // true String.__proto__ === Function.prototype // true Object.__proto__ === Function.prototype // true Function.__proto__ === Function.prototype //true Array.__proto__ === Function.prototype // true RegExp.__proto__ === Function.prototype // true Error.__proto__ === Function.prototype // true Date.__proto__ === Function.prototype // true <h2>2、js 引用类型与值类型</h2> <div>1.引用类型</div> > var a = {"x" : 1} ; > var b = a ; > a.x = 2; > console.log(b.x); //2 > a = { "x" : 3}; > console.log(b.x); //2 > <div>2.值类型</div> > var a = 88; > var b = a; > a = 98; > console.log(b); // 98 > b = 100; > console.log(b) ; // 100 > console.log(a) ; // 98 3.值类型跟引用类型的总结 >function abc(x){ > console.log(typeof (x)); //undefinded 值类型 > console.log(typeof (x)); //number 值类型 > console.log(typeof (‘abc’)); //string 值类型 > console.log(typeof (true)) ; //Boolean 值类型 > console.log(typeof (function(){ })) //function 引用类型 > console.log(typeof ([1,"a",,true])) //Array 引用类型 > console.log(typeof ({ a:10, b: 20})) //Object 或者json 引用类型 > console.log(typeof (null)); // null 引用类型 console.log(typeof (new Number(10))); //内置对象 引用类型 } >这里还有一道变态的前端面试题,仅限参考 >var a = { a: 1} ; >var b = a: >a.x = a = { a: 2 }; >console.log( a.x ); // --> undefined >console.log( b.x ) ; [ object Object ] > >到现在我都没搞懂这是其中的赋值问题 <h2>ES6 中的 var , let , const 的区别</h2> > 1.使用 var 声明的是变量,其作用域为该语句所在的函数内部,且存在变量提升现象 > 2.使用 let 声明的是变量,其作用域为该语句所在的代码块内,不存在变量提升 > 3.使用 const 声明的是常量,其作用域为该语句所在的代码块内,不存在变量提升, 值是不可修改更改的
- 粉丝: 8
- 资源: 1
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助