//队尾增加元素


var arr = [1,2,3,4,5];
var arr_push = arr.push(0);
console.log(arr); //原数组改变
console.log(arr_push); //返回修改后数组的长度

//队尾删除元素


var arr = [1,2,3,4,5];
var arr_pop = arr.pop(5);
console.log(arr);  //原数组改变
console.log(arr_pop); //返回删除的元素

//队头删除元素


var arr = [1,2,3,4,5];
var arr_shift = arr.shift();
console.log(arr); //原数组改变
console.log(arr_shift); //返回删除的元素

//队头增加元素


var arr = [1,2,3,4,5];
var arr_unshift = arr.unshift(5);
console.log(arr); //原数组改变
console.log(arr_unshift); //返回修改后数组的长度

//颠倒数组


var arr = [1,2,3,4,5];
var arr_reverse = arr.reverse();
console.log(arr); //原数组改变
console.log(arr_reverse); //返回颠倒后的数组

//连接两个数组


var arr = [1,2,3,4,5];
var arr1 = [6,7];
var arr_concat = arr.concat(arr1);
console.log(arr); //不改变
console.log(arr1);
console.log(arr_concat); //返回连接后的数组

//截取数组


var arr = [1,2,3,4,5];
var arr_slice = arr.slice(1,3);//arguments = [start_index,end_index]
var arr_slice2 = arr.slice(1); //end参数也可以没有 默认最后一个 
console.log(arr); //不改变
console.log(arr_slice); //返回截取的数组 [2,3]
console.log(arr_slice2); //arr_slice2 = [2,3,4,5]

//向特定位置添加删除元素


var arr = [1,2,3,4,5];
//arguments = index, num to delete, item to add , item to add...
var arr_splice = arr.splice(1,0,'item1','item2');
console.log(arr); //改变原数组 [ 1, 'item1', 'item2', 2, 3, 4, 5 ]
console.log(arr_splice);//[] 返回的是被删除的元素
var arr_splice2 = arr.splice(2,2);
console.log(arr_splice2);//[] [ 'item2', 2 ]

//截取字符串


var str = 'hello world';
var str_substr = str.substr(1,5);
console.log(str); //不改变原字符串
console.log(str_substr); //返回子串
var str_substring = str.substring(1,5);
console.log(str);
console.log(str_substring);

//字符串转数组


var str = 'h-e-l-l-o-w-o-r-l-d';
var str_split = str.split('-');
console.log(str); //不改变
console.log(str_split); 


//判断数组中是否含有某元素


var arr1 = ['runoob', 'google', 'taobao'];
var target = 'runoob';
var pd = arr1.includes(target);  //true
console.log(pd);

//数组转字符串


var arr = [1,2,3,4,5];
var arr_tostring = arr.toString(); 
console.log(arr); //不改变
console.log(arr_tostring); 


var parent = this.$el.parentNode 
// this.$el -> get the dom from the vue mode 
// dom.parentNode -> get the parent node (dom

this.wrapperArea = $(parent).find('.wrapper-area');
//$(parent) -> change js dom to jquery 
//.find()  -> jquery selector 
//this.wrapperArea is an array
var wrapperArea2 = parent.querySelector('.wrapper-area');
//only choose the first one found


李默
24 声望2 粉丝