Skip to content

Instantly share code, notes, and snippets.

@FreePhoenix888
Created July 12, 2024 06:47
Show Gist options
  • Save FreePhoenix888/ec069dfca416e4f9dfb723c156f69c14 to your computer and use it in GitHub Desktop.
Save FreePhoenix888/ec069dfca416e4f9dfb723c156f69c14 to your computer and use it in GitHub Desktop.
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