Javascript tricky snippets

Vineet Mishra
Nov 6, 2022

--

Q1. Guess the Output:

console.log(typeof(“John Doe”)) 
console.log(typeof(3.14))
console.log(typeof(true))
console.log(typeof(234567890123456789012345678901234567890n))
console.log(typeof(undefined))
console.log(typeof(null))
console.log(typeof(Symbol(‘symbol’)))

Take a breath , Don’t Jump into a solution

Output:
string
number
boolean
bigint
undefined
object
symbol

Q2. Guess the output

var value1 = 0;
var value2 = 23;

if(x) { console.log(value1) }

if(y) { console.log(value2) }

Take a breath , Don’t Jump into a solution

Output:23

--

--

Vineet Mishra
Vineet Mishra

Written by Vineet Mishra

SDE 2 at Accelya , I write about Mobile/Web Development and Deployment, and Interview Q & A

Responses (1)