js经典面试题

1. javaScript的基本类型有几种?

javaScript中分为七种内置类型,七种内置类型又分为两大类型:基本类型和对象(Object).。

基本类型有六种:null,undefined,boolean,number,string,symbol(ES6新增)。

2. typeof 判断 javaScript数据类型

详见:js中获取数据类型

3. 请写出下面运算结果

考隐式类型转换

[] + []       // “”(空字符串)
[] + {}      //"[object Object]"
{} + []      //0
{} + {}     //"[object Object][object Object]" (firefox下是NaN)
true + true       //2
1 + {a:1}         //"1[object Object]"

4. +0 与 -0

按照IEEE 754 规范

var foo = 0 / -3;
foo === -0;    //true
foo ===0;      //true
0 === -0;      //true

0 === -0;    //true 进行了一层处理,js最初进行表单处理,+0与-0实际上是无区别的;但是在有些特定情况是有区别且有意义的.

如何判断 0 与-0 ?

  (1)

function is0(num){
  return num === 0 && (1/num === -infinity)
}

 (2)ES6  object.is(x,y); 

5. 请描述一下new一个对象的过程

  

原文地址:https://www.cnblogs.com/Amy-world/p/9958709.html