Last active
October 15, 2020 19:48
-
-
Save jjhesk/fa46508000f986802a6ea3767d64769a to your computer and use it in GitHub Desktop.
JS Bin // source https://jsbin.com/vatojer
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
<!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> |
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
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