javascript sources
1 subscriber
1 photo
1 link
Hello world
Download Telegram
Forwarded from coding with ☕️
<input id="elem" type="button" value="Click me"/>
<script>
function handler1() {
alert('Thanks!');
};
function handler2() {
alert('Thanks again!');
}
elem.onclick = () => alert("Hello");
elem.addEventListener("click", handler1); // Thanks!
elem.addEventListener("click", handler2); // Thanks again!
</script>
Forwarded from coding with ☕️
button.addEventListener("click", () => alert("1"));
Forwarded from coding with ☕️
button.removeEventListener("click", () => alert("1"));
Forwarded from coding with ☕️
const fruits = ["Banana", "Orange", "Apple", "Mango"];
console.log(fruits);
Forwarded from coding with ☕️
const person = {
name: "Alice",
age: 15,
city:"New York"
};
console.log(person);
Forwarded from coding with ☕️
const person = {firstName:"John", lastName:"Doe", age:50, eyeColor:"blue"};
Forwarded from coding with ☕️
const person = {
firstName: "John",
lastName: "Doe",
age: 50,
eyeColor: "blue"
};
Forwarded from coding with ☕️
const person = {};

// Add Properties
person.firstName = "John";
person.lastName = "Doe";
person.age = 50;
person.eyeColor = "blue";
Forwarded from coding with ☕️
objectName.propertyName
objectName["propertyName"]
Forwarded from coding with ☕️
const person = {
firstName: "John",
lastName: "Doe",
age: 50,
eyeColor: "blue"
};

delete person.age;
console.log(person);
Forwarded from coding with ☕️
const person = {
firstName: "John",
lastName: "Doe",
id: 5566,
fullName: function() {
return this.firstName + " " + this.lastName;
}
};

// `fullName` metodini chaqirish va uning natijasini konsolga chiqarish
console.log(person.fullName());
Forwarded from coding with ☕️
person.name = function () {
return this.firstName + " " + this.lastName;
};
Forwarded from coding with ☕️
const person = {
firstName: "John",
lastName: "Doe",
id: 5566,
name: function () {
return this.firstName + " " + this.lastName;
}
};

// `name` metodini chaqirish va natijasini konsolga chiqarish
console.log(person.name());
Forwarded from coding with ☕️
```
//ORIENTED OPERATING PROGRAMMING

class Typing {
constructor({el, interval, delay}){
this.el = document.querySelector(el);
this.interval = interval || 500
this.delay = delay == undefined ? 1000 : delay
this.text = this.el.innerHTML.trim()
this.el.innerHTML = ""
setTimeout(() => this.write(i), this.delay);
}
write(i = 0){
this.el.innerHTML += this.text[i]
i++;
if (i < this.text.length) {
setTimeout(() => this.write(i), this.interval);
}

}
}
new Typing({
el: ".header__content h1" ,
interval: 300,
delay:1000
});