1. What is the object
对象是由多个键值对组成的无序的集合。对象中每个属性对应任意类型的值
2. Object Oriented what is
使用对象中的属性和方法就是面向对象
What are the local object 3.JavaScript What are the characteristics respectively
本地对象为array obj regexp等
特点是本地对象可以new实例化
What's built-in objects 4.JavaScript What are the characteristics
JavaScript常见的内置对象有
Object,Math,String,Array,Number,Function,Boolean,JSON 等
其中Object是所有对象的基类,采用了原型继承方式.
特点:内置对象不可以实例化
JavaScript host objects which
宿主为浏览器自带的document,window 等
The objects -js deep and shallow copy copy distinction
浅拷贝只复制指向某个对象的指针,而不复制对象本身,新旧对象还是共享同一块内存。
深拷贝会另外创造一个一模一样的对象,新对象跟原对象不共享内存,
修改新对象不会改到原对象。
Method 6. js deep copy of which:
递归拷贝
使用Object.create()方法
jquery 有提供一个$.extend也可以实现
函数库lodash,也有提供cloneDeep用来实现
7, which introduces built-in objects js there?
Object 是 JavaScript 中所有对象的父对象
数据封装类对象:Object、Array、Boolean、Number 和 String
其他对象:Function、Arguments、Math、Date、RegEx、Error
8.Javascript create objects in several ways? **
第一种:对象字面量、Object构造函数
第二种:构造函数
第三种:纯构造函数
第四种:空构造函数+原型
第五种:混合构造函数+原型
第六种:动态原型
第七种:寄生构造函数
第八种:Object.create()——ES5 ie9+
以下是寄生构造函数模式:
——其实是工厂模式的变种,只不过是放在其他构造函数中创建对象
代码如下:
function SpecialArray(){
var values = [];
values.push.apply(values, arguments);
values.toPipedString = function(){
return this.join("|");
};
return values;
}
var colors = new SpecialArray("red", "blue", "green");
alert(colors.toPipedString()); //"red|blue|green"