1. 链式调用
链式调用完方法后,return this返回当前调用方法的对象。优点是:链式调用这种风格有助于简化代码的编写工作,让代码更加简洁、易读,同时也避免多次重复使用一个对象变量
链式调用
//难点:链式调用 return this
var data = [
{
price: 11, name: "b-123"},
{
price: 21, name: "a-123"},
{
price: 14, name: "b-123"},
{
price: 15, name: "a-123"},
{
price: 12, name: "a-123"},
{
price: 18, name: null}
]
var find = function(origin) {
this.data = origin;
this.where = function(obj) {
let key = Object<