A resourceful newsletter featuring the latest and most important news, articles, books and updates in the world of #javascript π Don't miss our Quizzes!
Let's chat: @nairihar
Post #1951
7.06K
JA @javascript
Showing posts older than #1952 Β· Back to latest
function trickyFunction() {
var obj = { a: 1 };
var anotherObj = obj;
obj.a = 2;
obj = { a: 3 };
anotherObj.a = 4;
return obj.a + anotherObj.a;
}
console.log(trickyFunction());
function trickyFunction() {
var x = 10;
if (x > 5) {
let y = x * 2;
x = y;
}
return x;
}
console.log(trickyFunction());
function trickyFunction() {
var a = 10;
var b = a;
b = 15;
const obj1 = { x: 1 };
const obj2 = obj1;
obj2.x = 5;
console.log(a + ' ' + b + ' ' + obj1.x);
}
trickyFunction();
const obj = {
valueOf() {
return 42;
}
};
const result = obj + 8;
console.log(result);
function combine(...arrays) {
return arrays.reduce((acc, arr) => [...acc, ...arr], []);
}
const result = combine([1, 2], [3, 4], [5, 6]);
console.log(result);



