Канал о web-разработке. Новости IT, туториалы, веб-программирование и многое другое.
const person = {
name: "Kapil",
sayName() {
return this.name
}
}
person.sayName()
// Output: "Kapil"
Но:
const person = {
name: "Kapil",
sayName: () => this.name
}
person.sayName()
// Output: undefined
WebDEV #советы #coding #jsfunction doSomething(arg1){function doSomething (arg1)
10;
// Set arg1-10 as the default, if it isn't already.
Return arg1
}
let foo = 10;
foo ===10 && doSomething()
// is the same as "foo == 10") then doSomething()
// Output: 10.
doSomething();
// is the same as "foo!= 5" then doSomething()
// Output: 10.
WebDEV #советы #coding #js“”, null или 0.
const array = Array(5).fill('');
// Output
(5) ["", "", "", "", ""]
const matrix = Array(5).fill(0).map(()=>Array(5).fill(0));
// Output
(5) [Array(5), Array(5), Array(5), Array(5), Array(5)]
0: (5) [0, 0, 0, 0, 0]
1: (5) [0, 0, 0, 0, 0]
2: (5) [0, 0, 0, 0, 0]
3: (5) [0, 0, 0, 0, 0]
4: (5) [0, 0, 0, 0, 0]
length: 5
WebDEV #советы #js