const x = 5;
function p() {
return m()
}
function m() {
try {
return x;
} finally {
console.log('hi');
}
}
const z = {
p,
m,
}
m();
function Devs(name,age, job){
this.name = name;
this.age = age;
this.job = job;
this.presentation = function(style, timeOfDay){
if(style === 'formal'){
console.log(`Good ${timeOfDay}, Ladies and Gentlemen. I am ${this.name}
and I do ${this.job} for a living.
`)
}else if(style === 'casual'){
console.log(`Whats up guys ${timeOfDay}. You know me...I am ${this.name}
and I do ${this.job} for a living.`);
}else{
console.log(`Hi there , ${timeOfDay} Ladies and Gentlemen.`)
}
};
}
Devs.prototype.org = 'LinkedIn';
Devs.prototype.presentation = function(style, timeOfDay){
if(style === 'formal'){
console.log(`Good ${timeOfDay}, Ladies and Gentlemen. I am ${this.name}
and I do ${this.job} for a living.
`)
}else if(style === 'casual'){
console.log(`Whats up guys ${timeOfDay}. You know me...I am ${this.name}
and I do ${this.job} for a living.`);
}else{
console.log(`Hi there , ${timeOfDay} Ladies and Gentlemen.`)
}
};
let John = new Devs('John', 47, "Architect");
let Emily = new Devs('Emily', 37, "UXDesigner");
console.log(John.presentation === Emily.presentation);
//Emily.presentation = function(){};
John.presentation('casual','Morning');
Emily.presentation('formal','Evening');
console.log(Emily.org);
console.log(John.org);
function padLeft(value: string, padding: any) {
if (typeof padding === "number") {
return Array(padding + 1).join(" ") + value;
}
if (typeof padding === "string") {
return padding + value;
}
throw new Error(`Expected string or number, got '${padding}'.`);
}
(from server error logs; some work in javascript, don't have energy to minimize/debug)