热门
const originalText = 'Hello, World!'; const encodedText = encodeURIComponent(originalText); const decodedText = decodeURIComponent(encodedText);
const dateString = '2023-09-18'; const dateObject = new Date(dateString);
const template = 'Hello, {{name}}!'; const data = { name: 'Alice' }; const rendered = templateEngine(template, data); // 'Hello, Alice!'
const text = 'The quick brown fox jumps over the lazy dog.'; const replacedText = text.replaceAll('the', 'THE'); // 'The quick brown fox jumps over THE lazy dog.'
const text = 'apple,banana,cherry,date'; const fruits = text.split(',', 2); // ['apple', 'banana']
\n
const text = 'This is a new\nline.';
Array.prototype.reduce()
const words = ['Hello', 'World', '!']; const merged = words.reduce((result, word) => result + ' ' + word); // ' Hello World !'
const text = 'Hello! How are you? I am fine.'; const sentences = text.split(/[.!?]/); // ['Hello', ' How are you', ' I am fine', '']
const text = 'apple,banana,,cherry'; const fruits = text.split(',').filter(Boolean); // ['apple', 'banana', 'cherry']
const text = 'aabbccdd'; const uniqueText = Array.from(new Set(text)).join(''); // 'abcd'