Monday, September 5, 2022

The assign that I saw in the MDN

 function e() {return 3};

undefined

let c;

undefined


c = e();

3

c;

3

function g() {console.log('Hey')};

undefined

let d = g();

VM322:1 Hey

undefined

Some thing about assign an function to a variable, that is in the MDN, if the function is return a value will work, but if the function is like console.log('Say it') will not be done, even if you say the name and () that will came with is not a function and I can create an fucntion using the format variable name after the assign symbol the function, and the assigne will be of a function, so is two diferent things:

function f () {
  console.log('F!');
  return 2;
}
y = x = f()
y = [ f(), x = g() ]
x[f()] = g()
X will retrun 3;
and x[f()] will returnF!and undefinided and not the number, I even tried sum to it and returned F! NaN. So is like you capture just part of the command. Rute Bezerra de Menezes Gondim




No comments:

Post a Comment