Title: Object destructuring assignment does not work for variables initialized previously · Issue #361 · javascript-obfuscator/javascript-obfuscator · GitHub
Open Graph Title: Object destructuring assignment does not work for variables initialized previously · Issue #361 · javascript-obfuscator/javascript-obfuscator
X Title: Object destructuring assignment does not work for variables initialized previously · Issue #361 · javascript-obfuscator/javascript-obfuscator
Description: Expected Behavior Variable assignment without declaration when using object destructuring should work. According to destructuring assignment in MDN {a, b} = {a: 1, b: 2} is not valid stand-alone syntax, as the {a, b} on the left-hand sid...
Open Graph Description: Expected Behavior Variable assignment without declaration when using object destructuring should work. According to destructuring assignment in MDN {a, b} = {a: 1, b: 2} is not valid stand-alone sy...
X Description: Expected Behavior Variable assignment without declaration when using object destructuring should work. According to destructuring assignment in MDN {a, b} = {a: 1, b: 2} is not valid stand-alone sy...
Opengraph URL: https://github.com/javascript-obfuscator/javascript-obfuscator/issues/361
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Object destructuring assignment does not work for variables initialized previously","articleBody":"\u003c!-- Love javascript-obfuscator? Please consider supporting our collective:\r\n👉 https://opencollective.com/javascript-obfuscator/donate --\u003e\r\n\r\n\u003c!--- Provide a general summary of the issue in the Title above --\u003e\r\n\r\n## Expected Behavior\r\nVariable assignment without declaration when using object destructuring should work.\r\n\r\nAccording to [destructuring assignment in MDN](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Destructuring_assignment#Object_destructuring)\r\n\r\n\u003e {a, b} = {a: 1, b: 2} is not valid stand-alone syntax, as the {a, b} on the left-hand side is considered a block and not an object literal.\r\n\u003e \r\n\u003e However, ({a, b} = {a: 1, b: 2}) is valid, as is var {a, b} = {a: 1, b: 2}\r\n\r\n\u003c!--- If you're describing a bug, tell us what should happen --\u003e\r\n\u003c!--- If you're suggesting a change/improvement, tell us how it should work --\u003e\r\n\r\n## Current Behavior\r\nCurrently the variable name on left-hand side part of the statement is not being changed by the obfuscator while the initial variable declaration is.\r\n\r\nThis is the obfuscator output for the function below:\r\n```\r\nfunctiontest(_0x4bb6ab){\r\n\tlet_0x44c2ed=undefined;if(!![]){\r\n\t\t({\r\n\t\t\ta // \u003c- notice how a is not obfuscated\r\n\t\t}=_0x4bb6ab);\r\n\t}console[_0x1b95('0x0')](_0x44c2ed);\r\n}\r\n```\r\n\u003c!--- If describing a bug, tell us what happens instead of the expected behavior --\u003e\r\n\u003c!--- If suggesting a change/improvement, explain the difference from current behavior --\u003e\r\n\r\n## Steps to Reproduce (for bugs)\r\n\u003c!--- Provide a link to a live example, or an unambiguous set of steps to --\u003e\r\n\u003c!--- reproduce this bug. Include code to reproduce, if relevant --\u003e\r\n1. Simply run the obfuscator for the code example given below\r\n2.\r\n3.\r\n4.\r\n\r\n## Your Environment\r\n\u003c!--- Include as many relevant details about the environment you experienced the bug in --\u003e\r\n* Obfuscator version used: 0.18.1\r\n* Node version used: 8.2.1 (although it does matter)\r\n\r\n# Stack trace\r\n\u003c!--- Include stack trace --\u003e\r\n\r\n## Minimal working example that will help to reproduce issue\r\n\u003c!--- Include code --\u003e\r\n```\r\nfunction test(obj) {\r\n let a = undefined;\r\n if(true){\r\n ({a} = obj);\r\n }\r\n console.log(a);\r\n // this should print 1, running the same example after the obfuscation prints undefined\r\n}\r\n\r\ntest({a: 1});\r\n```\r\n","author":{"url":"https://github.com/skiritsis","@type":"Person","name":"skiritsis"},"datePublished":"2018-12-13T12:00:19.000Z","interactionStatistic":{"@type":"InteractionCounter","interactionType":"https://schema.org/CommentAction","userInteractionCount":2},"url":"https://github.com/361/javascript-obfuscator/issues/361"}
| route-pattern | /_view_fragments/issues/show/:user_id/:repository/:id/issue_layout(.:format) |
| route-controller | voltron_issues_fragments |
| route-action | issue_layout |
| fetch-nonce | v2:7b0aa814-2d0e-aad7-2afc-a6e8de88dd4a |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | B448:35EC8D:BE635E:1025366:6A62F52D |
| html-safe-nonce | 7f0aa5415ada064077e5ca3ee1e8b68bfd331b26ff45c538d74f67ba953e7bc5 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJCNDQ4OjM1RUM4RDpCRTYzNUU6MTAyNTM2Njo2QTYyRjUyRCIsInZpc2l0b3JfaWQiOiIyMjEzMDc2NzQ5OTkwNTk3NTciLCJyZWdpb25fZWRnZSI6ImlhZCIsInJlZ2lvbl9yZW5kZXIiOiJpYWQifQ== |
| visitor-hmac | adeadfd67fbed48aec9d556639321de244d7e573013332c6847a0e356287349d |
| hovercard-subject-tag | issue:390647041 |
| github-keyboard-shortcuts | repository,issues,copilot |
| google-site-verification | Apib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I |
| octolytics-url | https://collector.github.com/github/collect |
| analytics-location | / |
| fb:app_id | 1401488693436528 |
| apple-itunes-app | app-id=1477376905, app-argument=https://github.com/_view_fragments/issues/show/javascript-obfuscator/javascript-obfuscator/361/issue_layout |
| twitter:image | https://opengraph.githubassets.com/94aa517f6030d0090a43ae4bf9307b2449dbe78f0a8c6cd726ede03e575d3cac/javascript-obfuscator/javascript-obfuscator/issues/361 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/94aa517f6030d0090a43ae4bf9307b2449dbe78f0a8c6cd726ede03e575d3cac/javascript-obfuscator/javascript-obfuscator/issues/361 |
| og:image:alt | Expected Behavior Variable assignment without declaration when using object destructuring should work. According to destructuring assignment in MDN {a, b} = {a: 1, b: 2} is not valid stand-alone sy... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | skiritsis |
| hostname | github.com |
| expected-hostname | github.com |
| None | b415018e190e73858133ddcaa36acce7b3f3572fe54dda84bd3b21a6ec714c30 |
| turbo-cache-control | no-preview |
| go-import | github.com/javascript-obfuscator/javascript-obfuscator git https://github.com/javascript-obfuscator/javascript-obfuscator.git |
| octolytics-dimension-user_id | 23015672 |
| octolytics-dimension-user_login | javascript-obfuscator |
| octolytics-dimension-repository_id | 58360147 |
| octolytics-dimension-repository_nwo | javascript-obfuscator/javascript-obfuscator |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | false |
| octolytics-dimension-repository_network_root_id | 58360147 |
| octolytics-dimension-repository_network_root_nwo | javascript-obfuscator/javascript-obfuscator |
| turbo-body-classes | logged-out env-production page-responsive |
| disable-turbo | false |
| browser-stats-url | https://api.github.com/_private/browser/stats |
| browser-errors-url | https://api.github.com/_private/browser/errors |
| release | 22f98521e99f504294ab0812b66104d50eb75a70 |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
Links:
Viewport: width=device-width