const timers = document.querySelectorAll(".timer");
const item = document.querySelector(".item");
window.addEventListener("scroll", function luboy() {
console.log(this.scrollY + 2 * item.clientHeight);
console.log(item.offsetTop);
timers.forEach((time) => {
function rec(i = 0) {
time.innerHTML = i;
i++;
let count = +time.getAttribute("count");
if (i <= count) {
setTimeout(() => {
rec(i);
}, 10);
}
}
rec();
});
this.window.removeEventListener('scroll', luboy)
});btn.onclick = () => {
root.style.setProperty("--color',gold")
localStorage.setItem('color', 'gold')
}
btn.ondblclick = () => {
root.style.setProperty("--color',green")
localStorage.setItem('color', 'green')
}
})
root.style.setProperty('--color', localStorage.getItem("color"))function Person (firstName, lastName) {
this.firstName = firstName
this.lastName = lastName
}
const firstPerson = new Person("Fotima", "Nishonova")
const secondPerson = new Person("Zuhra", "Nishonova")
console.log(firstPerson);
console.log(secondPerson);
coding with ☕️
function Person (firstName, lastName) { this.firstName = firstName this.lastName = lastName } const firstPerson = new Person("Fotima", "Nishonova") const secondPerson = new Person("Zuhra", "Nishonova") console.log(firstPerson); console.log(secondPerson);
Function Contructor Obyekt qaytradi
this.hello = function() {
console.log(`Hello ${this.firstName} ${this.lastName} `); firstPerson.hello()
secondPerson.hello()function hello() {
console.log("Salom, dunyo!");
}
hello(); // Funksiyani chaqirish
coding with ☕️
function hello() { console.log("Salom, dunyo!"); } hello(); // Funksiyani chaqirish
1. Oddiy Funksiya Chaqirish
function sayHello(name) {
console.log("Salom, " + name + "!");
}
sayHello("Ali"); // Chaqirish: Salom, Ali!function sum(a, b) {
return a + b;
}
let result = sum(5, 3); // Chaqirish
console.log(result); // Natija: 8
coding with ☕️
function sum(a, b) { return a + b; } let result = sum(5, 3); // Chaqirish console.log(result); // Natija: 8
3. Return Qaytaruvchi Funksiya
let greet = function(name) {
return "Salom, " + name + "!";
};
console.log(greet("Hasan")); // Chaqirish
coding with ☕️
let greet = function(name) { return "Salom, " + name + "!"; }; console.log(greet("Hasan")); // Chaqirish
4. Anonim Funksiya (Function Expression)
const multiply = (a, b) => a * b;
console.log(multiply(4, 2)); // Chaqirish: 8