JSFiddle - React, Tailwind, and code Playground
JavaScript
x = 1;
y = 2;
function a(y) {
// y is local to the function, because it is a function parameter
alert(y); // 10
y = 3; // will only overwrite local y, not 'global' y
var x; // makes x a local variable
x = 4; // only overwrites local x
alert(y); // 3
alert(x); // 4
// global value could be by referencing outside scope by window object
alert(window.y) // 2 global y
}
a(10);
alert(x); // 1; this is the global value
alert(y); // 2; global as well