Get rid of the array with the shortest code, and welcome to the point of inadequacy.
/* Let numbers = [3, 8, ten, +]; Let num_test = [4, 5, ten, +]; */ = [3, 8, ten, 20].concat ([4, 5, ten, +]); =[]; $.each (Arr_num, (item, index)= { res.lengthnull ; }); Console.log (res); //
The previous wording for the use of some es6 is relatively brief, and the simple jquery notation is:
varNumbers = [3, 8, 10, 18, 20]; var num_test= [4, 5, 10, 18, 20]; varArr_num =Numbers.concat (num_test); varres =[]; $.each (Arr_num,function(item, index) {if(Res.length==0 | | ($.inarray (Index,res) ===-1) {res.push (index); }Else{return ;} }); Console.log (RES); //[3, 8, ten, 4, 5]
What about the question of return in the ternary operator, condition? Example 1: Example 2;
Online search without fruit, after practice to know (PS: ternary operator also called the trinocular operator)
The ternary operator/three-mesh operator Example 1 and Example 2 cannot be a statement that must have a value, and return is not a valid valued expression.
The first judgment I wrote was:
return ; // Error // syntaxerror:expected expression, got keyword ' return '
About return:
Retrun true; Returns the correct processing result. return false; Returns the processing result of the error, terminating processing. Return the control back to the page return null to continue execution
Therefore, when using the ternary operator really need to use return, you can directly write the result of return, to avoid the use of return easy to jump wrong
Use the shortest code to fix the array.