.eslintrc.js
. import { get } from 'lodash'
let link = get(msg, 'attachments[0].audio_message.link_mp3', '')
const newArr = arr.map((n, i) => n.repeat(i + 1));
const newArr = arr.map((n, i) => Array(i + 1).fill(n).join(''));
const newArr = arr.map((n, i) => Array(i + 2).join(n));
const newArr = [];
for (let i = 0; i < arr.length; i++) {
let str = '';
for (let j = 0; j <= i; j++) {
str += arr[i];
}
newArr.push(str);
}
const newArr = [];
for (const n of arr) {
let str = '';
while ((str = str.concat(n)).length <= newArr.length) ;
newArr[newArr.length] = str;
}
<div id="someId">
<!-- COMMENT One-->
<!-- COMMENT Two -->
<!-- {"json": true} -->
</div>
<output></output>
let out = document.querySelector('output');
let el = document.querySelector('#someId');
for (let i = 0; i < el.childNodes.length; i++) {
let child = el.childNodes[i];
if (child.nodeType == 8) {
console.log(child.textContent);
out.innerHTML += ' <br> ' + child.textContent;
}
}
decodeURIComponent(escape('Bj\u00c3\u00b6rn H\u00c3\u00bcttner'))
/**
* Decodes utf-8 encoded string back into multi-byte Unicode characters.
*
* Can be achieved JavaScript by decodeURIComponent(escape(str)),
* but this approach may be useful in other languages.
*
* @param {string} utf8String - UTF-8 string to be decoded back to Unicode.
* @returns {string} Decoded Unicode string.
*/
function utf8Decode(utf8String) {
if (typeof utf8String != 'string') throw new TypeError('parameter ‘utf8String’ is not a string');
// note: decode 3-byte chars first as decoded 2-byte strings could appear to be 3-byte char!
const unicodeString = utf8String.replace(
/[\u00e0-\u00ef][\u0080-\u00bf][\u0080-\u00bf]/g, // 3-byte chars
function(c) { // (note parentheses for precedence)
var cc = ((c.charCodeAt(0)&0x0f)<<12) | ((c.charCodeAt(1)&0x3f)<<6) | ( c.charCodeAt(2)&0x3f);
return String.fromCharCode(cc); }
).replace(
/[\u00c0-\u00df][\u0080-\u00bf]/g, // 2-byte chars
function(c) { // (note parentheses for precedence)
var cc = (c.charCodeAt(0)&0x1f)<<6 | c.charCodeAt(1)&0x3f;
return String.fromCharCode(cc); }
);
return unicodeString;
}