interview questions
by Krishna Ananthi
JavaScript
{
let x = {
a: 1,
b: 2
};
console.log(Object.values(x));
//or
let arr = [];
for (let c in x)
arr.push(x[c]);
console.log(arr);
let a = 'ananthi';
console.log(a.split('').reverse().join(''));
Array.prototype.print = function() {
console.log(this.toString());
};
[1, 2].print();
}
const a = function(x) {
this.x = x;
}
const b = function(x,y) {
this.y = y;/*
this.x = new a(x); */
a.call(this,x);
this.gety = () => {
return this.y;
}
this.getx = () => {
return this.x;
}
}
let newb = new b('x', 'y');
console.log(newb.getx());
console.log(newb.gety());