coding with ☕️
2 subscribers
262 photos
14 videos
11 files
165 links
Anwendungsentwicklung
Download Telegram
function ask(question, no, yes){
if(confirm(question))yes()
else no()
}
ask("do you agere?"
function(){alert{"You agreed!"}; },
function(){alert{"You canceled the execution!"}; }
);
let userName = prompt("Your name?", "Alice");
let isTeaWanted = confirm("Do you want some tea?");

alert( "Visitor: " + userName ); // Alice
alert( "Tea wanted: " + isTeaWanted ); // true
let isBoss = confirm("Are you the boss?");

alert( isBoss ); // true if OK is pressed
Object
let user = {     // an object
name: "John", // by key "name" store value "John"
age: 30 // by key "age" store value 30
};
function makeUser(name, age) {
return {
name: name,
age: age,
// ...other properties
};
}

let user = makeUser("John", 30);
alert(user.name); // John
let user = {
name: "John",
age: 30
};

user.sayHi = function() {
alert("Hello!");
};

user.sayHi(); // Hello!
let user = {
name: "John",
age: 30,

sayHi() {
// "this" is the "current object"
alert(this.name);
}

};

user.sayHi(); // John
let user = {
name: "John",
age: 30,

sayHi() {
alert(user.name); // "user" instead of "this"
}

};
function sayHi() {
alert( this.name );
}
function BigUser() {

this.name = "John";

return { name: "Godzilla" }; // <-- returns this object
}

alert( new BigUser().name ); // Godzilla, got that object
function BigUser(){
this.name = "Fotima"

return {name: "Godzila"};
}
alert(new BigUser().name );
console.log(new BigUser())
`with "New Operator" we can call in "console.log" with " ( ) "
function BigUser(){
this.name = "Fotima"

return {name: "Godzila"};
}
alert(new BigUser().name );
console.log(new BigUser().name)