DEV Community

Braincuber Technologies
Braincuber Technologies

Posted on

5 2

80 % of freshers fail to answers these javascript snippets 🔥

Q1. Guess the output:

var truth = true;
let havingFunction = function()
{
if (truth)
{
var name = “vineet”
let lastName= “mishra”
}
console.log(name)
console.log(lastName)
}
havingFunction()

Take a break don’t jump into output, think hard

Output:

vineet
ReferenceError: lastName is not defined

Reason: This happens due to the variable scope where name variable has function and lastName is having local scope

Q2. Guess the output:

console.log(3 > 2 > 1);
console.log(1 < 2 < 3);

take a break don’t jump into output, think hard

Output:

false
true

Reason: In the first section of the snippet where 3>2>1 is false because when programs run it go for 3>2 which is true and then it goes for the other part which becomes “true >1" where the value of true is 1 then equation becomes 1>1 which going to false, vice versa happens for another snippet which is 1<2< 3

Read more

Remix vs. Next.js: A Detailed Comparison

Top JavaScript VSCode Extensions for Faster Development 🔥

Postmark Image

Speedy emails, satisfied customers

Are delayed transactional emails costing you user satisfaction? Postmark delivers your emails almost instantly, keeping your customers happy and connected.

Sign up

Top comments (0)

The Most Contextual AI Development Assistant

Pieces.app image

Our centralized storage agent works on-device, unifying various developer tools to proactively capture and enrich useful materials, streamline collaboration, and solve complex problems through a contextual understanding of your unique workflow.

👥 Ideal for solo developers, teams, and cross-company projects

Learn more

👋 Kindness is contagious

Please leave a ❤️ or a friendly comment on this post if you found it helpful!

Okay