1.JS中使用typeof能得到的哪些類型?
typeof undefined // undefined
typeof 'abc' // string
typeof 123 // number
typeof true //boolean
typeof {} // object
typeof [] //object
typeof null // object
typeof console.log // function
2.何時使用 === 何時使用 ==
if (obj.a == null) {
// 這里相當于 obj.a === null || obj.a === underfined笙以, 簡寫形式
}
其他的情況用 ===
3.JS中有哪些內(nèi)置函數(shù) -- 函數(shù)封裝對象
Object
Array
Boolean
Number
String
Function
Date
RegExp
Error
4.JS變量按照存儲方式區(qū)分為哪些類型妓蛮,并描述其特點
- 值類型(真正拷貝茂嗓,重新分配內(nèi)存)
- 引用類型(并非真正拷貝,使用同一塊內(nèi)存)
5.如何理解JSON股缸?
6.如何準確判斷一個變量是數(shù)組類型?
var arr = []
arr instanceof Array //true
7. 寫一個原型鏈繼承的例子
function Animal() {
this.eat = function () {
console.log('animal eat')
}
function Dog() {
this.bark = function () {
console.log('dog bark')
}
}
Dog.prototype = new Animal()
var hashiqi = new Dog()
}
8.描述new一個對象的過程奥额?
- 創(chuàng)建一個對象
- this指向這個新對象
- 執(zhí)行代碼,即對this賦值
- 返回this