I'm trying to see where the value of the variable "y" comes from in a Javascript code and 2 lines above is the notation:
and || p () (0);
What does this mean?
I'm trying to see where the value of the variable "y" comes from in a Javascript code and 2 lines above is the notation:
and || p () (0);
What does this mean?
Although amenadiel gave a good answer, I want to give another reference and explaining what the operator refers to || when you work with variables like in the example you showed
function test(argument){
// Si el argumento no es dado se pondrá por defecto 'Hello world'
argument = argument || 'Hello world';
return argument;
}
console.log(test('Hola mundo')); // Hola mundo
console.log(test()); // Hello world
Then in your case
// Esto equivaldría a que si y no está definida y/o inicializada su valor dependerá de lo que retorne la función p()(0)
y || p()(0);
Example of the above:
function test(argument){
argument = argument || override('Hello world')
return argument;
}
function override(data){
return test(data);
}
console.log(test('Hola mundo')); // Hola mundo
console.log(test('Hey!')); // Hey!
console.log(test()); // Hello world
p
is a function that returns another function f
p()(0)
Equivalent to do
f(0)
That said, the expression
y || f(0)
Evaluate true
if y
or f(0)
are "true" ( truthy ).
With a minified code, it is no longer what can be said.