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
coding with ☕️
const multiply = (a, b) => a * b; console.log(multiply(4, 2)); // Chaqirish: 8
5. Arrow Function (ES6)
coding with ☕️
(function() { console.log("Bu funksiya avtomatik chaqiriladi!"); })();
6. Immediately Invoked Function Expression (IIFE)
const person = {
name: "Ali",
greet: function() {
console.log("Salom, men " + this.name);
}
};
person.greet(); // Chaqirish: Salom, men Ali