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 #1911
7.56K
- π€ 14
- π 7
- β€ 5
- π€£ 2
JA @javascript
Showing posts older than #1912 Β· Back to latest
var obj = {
a: 10,
b: 20,
c: 'hello'
};
with (obj) {
var sum = a + b;
var greeting = c + ' world';
}
console.log(sum, greeting);const numbers = [2, 4, 6, 8];
const sum = numbers.reduce((acc, num) => acc + num, 0);
console.log(sum);
const symbol1 = Symbol('desc1');
const symbol2 = Symbol('desc2');
const myObject = {};
myObject[symbol1] = 'Value1';
myObject[symbol2] = 'Value2';
let output = '';
for (let key in myObject) {
output += myObject[key] + ' ';
}
output += Object.getOwnPropertySymbols(myObject).length;
console.log(output);
class MyClass {
constructor() {
this.a = 10;
}
}
MyClass.prototype.b = 20;
const obj = new MyClass();
delete obj.b;
console.log(obj.b);

const map = new Map();
map.set("key", undefined);
console.log(map.has("key"), map.get("key"));
const obj = {
0: "zero",
1: "one",
length: 2
};
console.log(Array.from(obj));
function foo() {}
foo.prototype.bar = 42;
const obj = new foo();
foo.prototype = { bar: 100 };
console.log(obj.bar);