palindrome * *
"123" changed to "123321"
"abc321" changed to "ABCD321123CBA"
function fn (str) {
Convert string to string array (with or without spaces)
var arr=str.split (');
Console.log (arr);
Reverses the order of string arrays
var reversearr=arr.reverse ();
Console.log (Reversearr);
Stitching arrays of inverted order into strings (with or without spaces)
var reversestr=reversearr.join ("");
Console.log (REVERSESTR);
Stitch the original string together with the inverted string to get the result
return str+reversestr;
//Shorthand
//returen Str+str.split (""). Reverse.join ("");
}
Console.log (FN ("This was an apple");
Console.log (FN ("abc321"));
Detecting class names
function Checkclass (A, b) {
//Get class an array group
var allclass = A.split (");
Console.log (Allclass);
Determines whether the value of B has occurred in the array
If it does not appear (with: true, no: false)
var i=0;
var result=false;
For (; i<allclass.length;i++) {
if (allclass[i]===b) {
If these two values are equal, the value of an item in the array is equal to B, and the previous assumption is wrong.
result=true;
Break ;
}
}
return result;
}
The IndexOf method, if not found, returns-1, if found, returns the angle label of the array
if (allclass.indexof (b) = = = 1) {
return false;
} else {
return true;
}
}
Console.log (Checkclass ("Name right", "right"));
Console.log (Checkclass ("Name right", "left");
var obj1 = {
A:10,
B:20
};
?
var obj2 = obj1;
?
obj1.a = 30;
?
Console.log (obj2.a);
Console.log (obj1.a);
?
Reference type: When assigning data of a reference type to a variable, it does not assign the data itself to the variable, but instead assigns the reference to the variable
?
var arr = [1, 2, 3];
var arr2 = arr;
ARR[1] = 10;
Console.log (ARR2);
The detection method of JavaScript palindrome and class name