<script>
const text = "Hello World\r\n2021";
text.replace(/(\n|\r|\r\n|↵)/g, "<br/>");
// console.log(text);
const fruits = [
{ name: "Apple", color: "red" },
{ name: "Banana", color: "yellow" },
{ name: "Cherry", color: "red" },
{ name: "Lemon", color: "yellow" },
{ name: "Grape", color: "purple" },
];
const fruitsByColor = Object.groupBy(fruits, (fruit) => fruit.color);
console.log(fruitsByColor);
let newstring = "2024-07-17";
console.log(newstring.slice(0, 4));
let newstring2 = "20240101";
let endRes =
newstring2.slice(0, 4) +
"-" +
newstring2.slice(4, 6) +
"-" +
newstring2.slice(6, 8);
console.log(endRes);
function isOdd(n) {
return !n % 2;
}
console.log(isOdd(0));
console.log(isOdd(-2));
</script>
最近用的方法
最新推荐文章于 2024-09-04 11:56:14 发布