Skip to content

Instantly share code, notes, and snippets.

@jjhesk
Last active October 15, 2020 19:48
Show Gist options
  • Save jjhesk/fa46508000f986802a6ea3767d64769a to your computer and use it in GitHub Desktop.
Save jjhesk/fa46508000f986802a6ea3767d64769a to your computer and use it in GitHub Desktop.
JS Bin // source https://jsbin.com/vatojer
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width">
<title>JS Bin</title>
</head>
<body>
<script src="https://cdn.rawgit.com/zloirock/core-js/master/client/shim.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/es5-shim/2.0.8/es5-shim.min.js"></script>
<script id="jsbin-javascript">
const TRAILING_ARRAY_REGEX = /\[\d*\]$/;
const dataItem= {
"internalType": "uint256[17]",
"name": "accountinfo",
"type": "uint256[17]"
};
const newItem = Object.assign(dataItem, {
type: dataItem.type.replace(TRAILING_ARRAY_REGEX, "")});
console.log(newItem);
</script>
<script id="jsbin-source-javascript" type="text/javascript">const TRAILING_ARRAY_REGEX = /\[\d*\]$/;
const dataItem= {
"internalType": "uint256[17]",
"name": "accountinfo",
"type": "uint256[17]"
};
const newItem = Object.assign(dataItem, {
type: dataItem.type.replace(TRAILING_ARRAY_REGEX, "")});
console.log(newItem);</script></body>
</html>
const TRAILING_ARRAY_REGEX = /\[\d*\]$/;
const dataItem= {
"internalType": "uint256[17]",
"name": "accountinfo",
"type": "uint256[17]"
};
const newItem = Object.assign(dataItem, {
type: dataItem.type.replace(TRAILING_ARRAY_REGEX, "")});
console.log(newItem);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment