Untitled
unknown
plain_text
a year ago
3.3 kB
9
Indexable
console.log(typeof NaN);
let a = [1, 2, 3];
let b = a;
b[0] = 4;
console.log(a);
console.log('5' - 2);
function foo() {
return
{
bar: "Hello"
};
}
console.log(foo());
const obj = { a: 1, b: 2 };
console.log(Object.keys(obj).map(key => obj[key]));
console.log([1, 2] == [1, 2]);
let x = 10;
function test() {
console.log(x);
let x = 20;
}
test();
const f = (x) => {
return (y) => {
return x + y;
};
};
const add5 = f(5);
console.log(add5(10));
console.log((1, 2, 3));
let count = 0;
const increment = () => {
count++;
return count;
};
console.log(increment());
console.log(increment());
const arr = [1, 2, 3, 4];
const doubled = arr.map(n => n * 2);
console.log(arr);
console.log(1 + '2' + 3);
const a = { name: 'John' };
const b = a;
b.name = 'Jane';
console.log(a.name);
console.log(0.1 + 0.2 === 0.3);
let x = [1, 2, 3];
let y = x;
y.push(4);
console.log(x);
console.log((function() {
return
{
message: "Hello"
};
})());
console.log(typeof ({}));
console.log(typeof "Hello" == "string");
let obj = { x: 1 };
let obj2 = Object.create(obj);
console.log(obj2.x);
function outer() {
let count = 0;
function inner() {
count++;
return count;
}
return inner;
}
const counter = outer();
console.log(counter());
console.log(counter());
let x = 1;
if (function f() {}) {
x += typeof f;
}
console.log(x);
const nums = [1, 2, 3];
const newNums = [...nums];
newNums[0] = 4;
console.log(nums);
console.log(3 == 3.0);
console.log(typeof (1 + '1'));
const obj = {
prop: 'value',
getProp() {
return this.prop;
}
};
console.log(obj.getProp());
let result = (function() {
return this || 'default';
})();
console.log(result);
const a = 1;
const b = a;
console.log(b === a);
let str = "Hello";
str[0] = "h";
console.log(str);
console.log([2] == [2]);
const arr = [1, 2, 3];
arr[10] = 10;
console.log(arr.length);
const foo = {
bar: 1,
baz: function() {
console.log(this.bar);
}
};
const fn = foo.baz;
fn();
let sum = 0;
for (let i = 0; i < 5; i++) {
setTimeout(() => {
sum += i;
}, 100);
}
setTimeout(() => console.log(sum), 200);
console.log(1 + 2 + '3' + 4 + 5);
let a = { x: 1 };
let b = { x: 1 };
console.log(a == b);
const a = [1, 2, 3];
const b = a;
b.push(4);
console.log(a);
const obj = { a: 1 };
Object.freeze(obj);
obj.a = 2;
console.log(obj.a);
const numbers = [1, 2, 3];
numbers.length = 0;
console.log(numbers);
console.log(1 < 2 < 3);
const fn = () => {
return { key: 'value' };
};
console.log(fn());
let x = 0;
setTimeout(() => {
console.log(x);
}, 0);
x++;
console.log((2, 3, 4));
const fn = () => {
return () => {
return 5;
};
};
console.log(fn()());
let num = 1;
const obj = {
num: 2,
getNum: function() {
return this.num;
}
};
console.log(obj.getNum());
const arr = [1, 2, 3];
arr.length = 2;
console.log(arr);
console.log(null == undefined);
console.log(0 == '0');
const func = function() {
return
{
name: "John"
};
};
console.log(func());
console.log('a' + 1 - 1);
const arr = [1, 2, 3];
console.log(arr[3] === undefined);
const obj = { a: 1, b: 2 };
console.log(Object.entries(obj));Editor is loading...
Leave a Comment