Search: #JavaScriptRiddle
🤖 JavaScript Conundrum! 🧩
To all the coding pros out there, here’s a quick test!
What does typeof null return in JavaScript?
A) ‘null’
B) ‘object’
C) ‘undefined’
Drop your guess in the comments! 📥 No Googling ! 🔍 #JavaScriptRiddle #WebDevTest #KnowYourCode #html #css #javascript
#JavaScript #Riddle what's the output of this code:
class X {
v = 1;
f() { return this.v }
g = () => this.v
}
const x = new X
console.log(x.g())
console.log(x.f())
const f = x.f
const g = x.g
console.log(g())
console.log(f())
#JavaScriptRiddle
#JavaScript #Riddle - haven't had one in a while 🙂 What's the exact output:
const x = {};
x.b = 1;
x[2] = 2;
x[1] = 3;
x[Symbol()] = 4;
x.a = 5;
console.log(...Object.values(x)); // ?
#JavaScriptRiddle
Presented as 6 methods but it's really only 2. Anyway, cool JavaScript riddle but don't ask this in a job interview #JavaScriptRiddle
javascript.plainenglish.io/i… – at Israel
Haven't done one in a while #JavaScriptRiddle
try {
switch (true) {
case 1 < 2:
console.log('hello');
case 2 > 3:
console.log('world');
}
} catch {
console.log('bye');
}
What's the output?
#JavaScript #Riddle
Replying to @MichalPorag
First, if you enjoy such things, checkout my #javascriptriddle tweets.
Also, since const and let are block-scoped, I hardly use IIFEs anymore.
#JavaScript #Riddle without checking, is this legal and if so what's the value of x:
const x = {...[]}
And is this legal and if so what's the value of y:
const y = [...{}]
#JavaScriptRiddle
#JavaScript #Riddle: what's the output?
function a() {}
function b(x) {}
function c(x = 1) {}
function d(...x) {}
console.log(a.length, b.length, c.length, d.length)
#JavaScriptRiddle
Another #JavaScript #Riddle about the spread operator:
let x;
let y = {...x};
let z = [...x];
What are the values of x, y and z? #JavaScriptRiddle
#JavaScript #Riddle:
const a = [1,2]
const x = {v:1}
const b = [...a]
const y = {...x}
console.log(...b)
console.log(...y)
Is this correct JS? What's the output?
#JavaScriptRiddle
Think you know #JavaScript symbols? How many hellos will this display:
const s = Symbol()
const x = {[s]:'hello'}
console.log(x[s])
for (v in x) console.log(v)
const y = {...x}
console.log(y[s])
console.log(Object.values(y)[0])
#JavaScriptRiddle
#riddle: this is now valid #javascript
const a = 1_000; // a is 1000
But what about:
const b = 1,000;
Is this valid? And if so, what's the value of b? #JavaScriptRiddle
#JavaScript riddle: what's the value of x?
function f() {
try {
return 1;
} finally {
return 2;
}
}
const x = f()
#JavaScriptRiddle #CodingNewbie #100DaysOfCode
Thanks for sharing Dan :) #JavaScript #JavaScriptRiddle
Replying to @debug_mode @getify
To all those he enjoyed figuring out and understanding how and why #JavaScript behaves this way, you may also enjoy the JS riddles I occasionally post. Just check out the hashtag #JavaScriptRiddle Scroll down and see how many you can solve ☺️
Replying to @debug_mode @getify
To all those he enjoyed figuring out and understanding how and why #JavaScript behaves this way, you may also enjoy the JS riddles I occasionally post. Just check out the hashtag #JavaScriptRiddle Scroll down and see how many you can solve ☺️
#JavaScript #riddle: what's the output and why?
function f() {
console.log(g);
{
function g() {}
}
}
f();
#JavaScriptRiddle
34%Uncaught ReferenceError
45%undefined
21%f g() {}
97 votes • Final results#JavaScript riddle - what's the output:
async function* g() {
yield 1;
yield 2;
}
async function f() {
for await (const v of g()) console.log(v);
console.log(3);
}
f(); f(); console.log(4);
#JavaScriptRiddle
Start your #JavaScript programming day with a bit of fun and learning: my @JSCampRo talk "JavaScript Riddles For Fun And Profit" youtube.com/watch?v=uaGLxAnR… #JavaScriptRiddle
Next month at @JSCampRo I'll be giving #JavaScript Riddles talk. Here's an example - is this valid code, and if so, what's the output:
const a="b"
const {[a]:b}={b:[a]}
console.log(b) // ?
What fun we will have! #JavaScriptRiddle
Silly #JavaScript #Riddle: what's the output of the following code?
var a = [3,2].map(v=>[v])
[1,0].forEach(v=>console.log(v,a))
Running in the console is cheating 😉 #JavaScriptRiddle



