JSFiddle - React, Tailwind, and code Playground
HTML
<script src="https://code.jquery.com/jquery-2.2.4.min.js"></script>
JavaScript
var notWorks = {
aa: "string",
bb: "str"
}
function why() {
var thisWorks = notWorks;
$.get("/echo/json").then(function() {
printVal(notWorks);
printVal(thisWorks);
});
notWorks = {};
}
function printVal(val) {
console.log(val);
}
why();