И если CryptoJS.SHA512("hello") возвращает корректный хэш строки "hello", то уже i = CryptoJS.SHA512(i) хэширует не строку hello, а инстанс объекта CryptoJS.
Ну и сформулирую вопрос более широко: как мне добиться того, чтобы результат кода исполняемого на C++ был идентичен результату кода исполненного на JS?
const arr = Array.from(
new Set(Array.from(document.querySelectorAll('.shop_name'), n => n.innerText)),
n => ({ name: n })
);
const arr = Object.values(Array.prototype.reduce.call(
document.getElementsByClassName('shop_name'),
(acc, { textContent: name }) => (acc[name] ??= { name }, acc),
{}
));
success: function(response){
setTimeout(function() {
document.location.href = `site.ru/test.php?number=${response.number}&name=${response.name}`;
}, 2000);
}
success: function(response){
localStorage.setItem('some_key', JSON.stringify(response.data));
setTimeout(function() {
document.location.href = 'site.ru/test.php';
}, 2000);
}
let helloHabr = JSON.parse(localStorage.getItem('some_key'));
function shortNumber(val) {
const abs = Math.abs(val);
const prefixIndex = Math.log10(abs) / 3 | 0;
return (
(val < 0 ? '-' : '') +
Math.round(abs / (10 ** (prefixIndex * 3))) +
'KMGTPEZY'.charAt(~-prefixIndex)
);
}
shortNumber(99) // '99'
shortNumber(1945) // '2K'
shortNumber(-5839465) // '-6M'
shortNumber(7e10) // '70G'
[].toString() + true + false - null
"" + true // "true"
"" + true + false // "truefalse"
"" + true + false - null // NaN
+
не строка, то это не конкатенация и true, false, null будут преобразованы к числам.true + false - null + [].toString()
1 + 0 // 1
1 + 0 - 0 // 1
1 + 0 - 0 + "" // "1"
const elements = document.querySelectorAll('.slider__itm img');
const tag = 'a';
elements.forEach(n => {
n.after(document.createElement(tag));
n.nextSibling.append(n);
});
for (const n of elements) {
const wrapper = document.createElement(tag);
wrapper.appendChild(n.parentNode.replaceChild(wrapper, n));
}
for (let i = 0; i < elements.length; i++) {
const wrapper = document.createElement(tag);
elements[i].replaceWith(wrapper);
wrapper.insertAdjacentElement('afterbegin', elements[i]);
}
(function next(i, n = elements.item(i)) {
n && (n.outerHTML = `<${tag}>${n.outerHTML}</${tag}>`, next(-~i));
})(0);