Common JS functions

Time:2021-9-14

JavaScript

Array inversion: after the element [0,1,2] in arr is inverted: [2,1,0]

arr.reverse();

For loop

for (i = 0; i < arr.length; i++) { 
   
 };
arr.forEach(function(value,index,array){
		console.log(value);
		console.log(index);
		console.log(array);
});

Determine whether a value exists in the array

let arr = [
  { num: 1, val: 'ceshi', flag: 'aa' },
  { num: 2, val: 'ceshi2', flag: 'aa2'  }
]
arr.filter(item => item.num===2 );

angularjs

angular.forEach(arr ,function(item,index,array){
        if(item==xx){
        }
 });

vue

Wechat applet

uniapp

layui

bootstrap

color ui