2// of the computer running the
3// code and stores it in the
4// variable ip
5export let ip; 6getPublicIP((ipAddress) => (ip = ipAddress));
7
8function getPublicIP(callback) {
In JavaScript, variables can be assigned during declaration, or at any point afterwards using an assignment statement. For example, in the following code, foo
is initialized during declaration, while bar
is initialized later.
var foo = 1;
var bar;
if (foo) {
bar = 1;
} else {
bar = 2;
}
function foo() {
var bar;
let baz;
}
function foo() {
var bar = 1;
let baz = 2;
const qux = 3;
}