Created
July 12, 2024 06:47
-
-
Save FreePhoenix888/ec069dfca416e4f9dfb723c156f69c14 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function serialize(numbers) { | |
return numbers.map(num => String.fromCharCode(num)).join(''); | |
} | |
function deserialize(str) { | |
return str.split('').map(char => char.charCodeAt(0)); | |
} | |
let numbers = [1, 5, 10, 255, 300]; | |
let serialized = serialize(numbers); | |
let deserialized = deserialize(serialized); | |
console.log('Исходный массив чисел:', numbers); | |
console.log('Сериализованная строка:', serialized); | |
console.log('Десериализованный массив чисел:', deserialized); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment