Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

164
Views
What is the difference in assigning a processed value directly to a variable and assigning without processing and then processed using && operator

I saw a function that receives a string parameter then performs some operations with it; like this:

const val = this.searchParam && this.searchParam.trim().toLowerCase();

My question is, why don't assign directly the processed string? Like this:

const val = this.searchParam.trim().toLowerCase();

I tried this in JS Bin to see if there's a difference, and the result is the same.

What do they exactly use the && operator?

about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

In code snippet below, the first log writes undefined, the second throws an error:

searchParam = undefined

console.log(searchParam && searchParam.trim().toLowerCase());
console.log(searchParam.trim().toLowerCase());

Therefore, the result is not the same

about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!