23

Github GitHub - yeungon/In-JavaScript-we-trust: Embrace JavaScript naturally and...

 3 years ago
source link: https://github.com/yeungon/In-JavaScript-we-trust
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.
neoserver,ios ssh client

README.md

In JS we trust - The best way to learn is by building/coding and teaching. I create the challenges to help my friends learn JavaScript and in return it helps me embrace the language in much deeper level. Feel free to clone, fork and pull.


1. What's the output?
function a(x) {
  x++;
  return function () {
    console.log(++x);
  };
}

a(1)();
a(1)();
a(1)();

let x = a(1);
x();
x();
x();
  • A: 1, 2, 3 and 1, 2, 3
  • B: 3, 3, 3 and 3, 4, 5
  • C: 3, 3, 3 and 1, 2, 3
  • D: 1, 2, 3 and 3, 3, 3
Answer
2. What's the output?
function Name(a, b) {
  this.a = a;
  this.b = b;
}

const me = Name("Vuong", "Nguyen");

console.log(!(a.length - window.a.length));
  • A: undefined
  • B: NaN
  • C: true
  • D: false
Answer
3. What's the output?
const x = function (...x) {
  let k = (typeof x).length;
  let y = () => "freetut".length;
  let z = { y: y };

  return k - z.y();
};

console.log(Boolean(x()));
  • A: true
  • D: false
Answer
4. What's the output?
(function js(x) {
  const y = (j) => j * x;

  console.log(y(s()));

  function s() {
    return j();
  }

  function j() {
    return x ** x;
  }
})(3);
  • A: undefined
Answer
5. What's the output?
var tip = 100;

(function () {
  console.log("I have $" + husband());

  function wife() {
    return tip * 2;
  }

  function husband() {
    return wife() / 2;
  }

  var tip = 10;
})();
  • A: "I have $10";
  • B: "I have $100";
  • C: "I have $50";
  • D: "I have $NaN";
Answer
6. What's the output?
const js = { language: "loosely type", label: "difficult" };

const edu = { ...js, level: "PhD" };

const newbie = edu;

delete edu.language;

console.log(Object.keys(newbie).length);

Answer7. What's the output?

var candidate = {
  name: "Vuong",
  age: 30,
};

var job = {
  frontend: "Vuejs or Reactjs",
  backend: "PHP and Laravel",
  city: "Auckland",
};

class Combine {
  static get() {
    return Object.assign(candidate, job);
  }

  static count() {
    return Object.keys(this.get()).length;
  }
}

console.log(Combine.count());

Answer8. What's the output?

var x = 1;

(() => {
  x += 1;
  ++x;
})();
((y) => {
  x += y;
  x = x % y;
})(2);
(() => (x += x))();
(() => (x *= x))();

console.log(x);
  • B: 50;
  • D: 10;
Answer
9. What's the output?
$var = 10;

$f = function($let) use ($var) {
    return ++$let + $var;
};

$var = 15;
echo $f(10);
var x = 10;

const f = (l) => ++l + x;

x = 15;
console.log(f(10));
  • A: 26 and 26;
  • B: 21 and 21;
  • C: 21 and 26;
  • D: 26 and 21;
Answer
10. What's the output?
let x = {};
let y = {};
let z = x;

console.log(x == y);
console.log(x === y);
console.log(x == z);
console.log(x === z);
  • A: true true true true;
  • B: false false false false;
  • C: true true false false;
  • D: false false true true;
Answer
11. What's the output?
console.log("hello");

setTimeout(() => console.log("hey"), 1);
setTimeout(() => console.log("kiora"), 2);
setTimeout(() => console.log("world"), 0);

console.log("hi");
  • A: "hello" "hey" "kiora" "world" "hi"
  • B: "hello" "hi" "hey" "kiora" "world"
  • C: "hello" "hi" "world" "hey" "kiora"
  • D: "hello" "hi" "hey" "world" "kiora"
Answer
12. What's the output?
String.prototype.lengthy = () => {
  console.log("hello");
};

let x = { name: "Vuong" };

delete x;

x.name.lengthy();
  • A: "Vuong";
  • B: "hello";
  • C: "undefined"
  • D: "ReferenceError"
Answer
13. What's the output?
let x = {};

x.__proto__.hi = 10;

Object.prototype.hi = ++x.hi;

console.log(x.hi + Object.keys(x).length);
  • D: NaN
Answer
14. What's the output?
const array = (a) => {
  let length = a.length;
  delete a[length - 1];
  return a.length;
};

console.log(array([1, 2, 3, 4]));

const object = (obj) => {
  let key = Object.keys(obj);
  let length = key.length;
  delete obj[key[length - 1]];

  return Object.keys(obj).length;
};

console.log(object({ 1: 2, 2: 3, 3: 4, 4: 5 }));

const setPropNull = (obj) => {
  let key = Object.keys(obj);
  let length = key.length;
  obj[key[length - 1]] = null;

  return Object.keys(obj).length;
};

console.log(setPropNull({ 1: 2, 2: 3, 3: 4, 4: 5 }));
  • A: 333
  • B: 444
  • C: 434
  • D: 343
Answer
15. What's the output?
var a = [1, 2, 3];
var b = [1, 2, 3];

var c = [1, 2, 3];
var d = c;

var e = [1, 2, 3];
var f = e.slice();

console.log(a === b);
console.log(c === d);
console.log(e === f);
  • A: true true true
  • B: false false true
  • C: true true false
  • D: false true false
Answer
16. What's the output?
var languages = {
  name: ["elixir", "golang", "js", "php", { name: "feature" }],
  feature: "awesome",
};

let flag = languages.hasOwnProperty(Object.values(languages)[0][4].name);

(() => {
  if (flag !== false) {
    console.log(
      Object.getOwnPropertyNames(languages)[0].length <<
        Object.keys(languages)[0].length
    );
  } else {
    console.log(
      Object.getOwnPropertyNames(languages)[1].length <<
        Object.keys(languages)[1].length
    );
  }
})();
  • B: NaN
Answer
17. What's the output?
var player = {
  name: "Ronaldo",
  age: 34,
  getAge: function () {
    return ++this.age - this.name.length;
  },
};

function score(greeting, year) {
  console.log(
    greeting + " " + this.name + `! You were born in  ${year - this.getAge()}`
  );
}

window.window.window.score.call(window.window.window.player, "Kiora", 2019);

score.apply(player, ["Kiora", 2009]);

const helloRonaldo = window.score.bind(window.player, "Kiora", 2029);

helloRonaldo();
  • A: "Kiora Ronaldo! You were born in 1985", "Kiora Ronaldo! You were born in 1985", "Kiora Ronaldo! You were born in 1985"
  • B: "Kiora Ronaldo! You were born in 1991", "Kiora Ronaldo! You were born in 1991", "Kiora Ronaldo! You were born in 1999"
  • C: "Kiora Ronaldo! You were born in 1991", NaN, "Kiora Ronaldo! You were born in 1980"
  • D: "Kiora Ronaldo! You were born in 1991", "Kiora Ronaldo! You were born in 1980", "Kiora Ronaldo! You were born in 1999"
Answer
18. What's the output?
var ronaldo = { age: 34 };

var messi = { age: 32 };

function score(year, tr, t) {
  if (typeof tr === "function" && typeof t === "function") {
    console.log(`You score ${tr(year, t(this.age))} times`);
  }
}

const transform = (x, y) => x - y;

const title = (x) => ++x + x++;

const helloRonaldo = score.bind(ronaldo, 2029, transform, title);

helloRonaldo();

const helloMessi = score.bind(messi, 2029, transform, title);

helloMessi();
  • A: "You score 1989 times" and "You score 1963 times"
  • B: "You score 1959 times" and "You score 1989 times"
  • C: "You score 1989 times" and "You score 1953 times"
  • D: "You score 1959 times" and "You score 1963 times"
Answer
19. What's the output?
var person = {};

Object.defineProperties(person, {
  name: {
    value: "Vuong",
    enumerable: true,
  },
  job: {
    value: "developer",
    enumerable: true,
  },
  studying: {
    value: "PhD",
    enumerable: true,
  },
  money: {
    value: "NZD",
    enumerable: false,
  },
});

class Evaluate {
  static checkFlag(obj) {
    return Object.getOwnPropertyNames(obj) > Object.keys(obj)
      ? Object.getOwnPropertyNames(obj)
      : Object.keys(obj);
  }
}

const flag = Evaluate.checkFlag(person);

console.log(flag.length);

Answer20. What's the output?

const id = 10;

const getID = (...id) => {
  id(id);

  function id(id) {
    console.log(typeof id);
  }
};

getID(id);
  • A: ReferenceError
  • C: undefined
  • D: 'function'
Answer
21. What's the output?
var book1 = {
  name: "Name of the rose",
  getName: function () {
    console.log(this.name);
  },
};

var book2 = {
  name: { value: "Harry Potter" },
};

var bookCollection = Object.create(book1, book2);

bookCollection.getName();
  • A: 'Harry Potter'
  • B: 'Name of the rose'
  • C: ReferenceError
  • D: Object object
Answer
22. What's the output?
(() => {
  const a = Object.create({});

  const b = Object.create(null);

  let f1 = a.hasOwnProperty("toString");

  let f2 = "toString" in b;

  let result =
    f1 === false && f2 === false
      ? console.log((typeof a.toString()).length)
      : console.log(b.toString());
})();
  • A: ReferenceError
  • B: undefined
Answer
23. What's the output?
let promise = new Promise((rs, rj) => {
  setTimeout(() => rs(4), 0);

  Promise.resolve(console.log(3));

  console.log(2);
});

promise
  .then((rs) => {
    console.log(rs ? rs ** rs : rs);
    return rs;
  })
  .then((rs) => console.log(rs == 256 ? rs : rs * rs));
  • A: 3, 2, 256, 256
  • B: 3, 2, 256, 16
  • C: 256, 16, 3, 2
  • D: 16, 256, 3, 2
Answer
24. What's the output?
async function f() {
  let promise = new Promise((resolve, reject) => {
    setTimeout(() => resolve("done!"), 0);
  });

  setTimeout(() => console.log("world"), 0);

  console.log(await promise);

  console.log("hello");
}

f(setTimeout(() => console.log("kiora"), 0));
  • A: ReferenceError
  • B: done, hello, world
  • C: hello, done, world
  • D: kiora, done, hello, world
Answer
25. What's the output?
function name() {
  return new Promise((resolve) => {
    setTimeout(() => {
      resolve("New Zealand");
    }, 10);
  });
}

function fruit() {
  return new Promise((resolve) => {
    setTimeout(() => {
      resolve("Kiwi");
    }, 20);
  });
}

(async function countryandfruit() {
  const getName = await name();
  const getFruit = await fruit();

  console.log(`Kiora: ${getName} ${getFruit}`);
})();

(async function fruitandcountry() {
  const [getName, getFruit] = await Promise.all([name(), fruit()]);

  console.log(`Hello: ${getName} ${getFruit}`);
})();
  • A: Null
  • B: Kiora
  • C: "Hello: New Zealand Kiwi" -> "Kiora: New Zealand Kiwi"
  • D: "Kiora: New Zealand Kiwi" -> "Hello: New Zealand Kiwi"
Answer
26. What's the output?
class MySort {
  constructor(object) {
    this.object = object;
  }

  getSort() {
    return Object.entries(this.object)[0][1].sort()[
      Object.values(this.object).length
    ];
  }
}

const object = {
  month: ["July", "September", "January", "December"],
};

const sortMe = new MySort(object);

console.log(sortMe.getSort());
  • A: July
  • B: September
  • C: January
  • D: December
Answer
27. What's the output?
const flag = [] !== !!!!![];

let f = () => {};

console.log((typeof f()).length + flag.toString().length);
  • A: NaN
Answer
28. What's the output?
(function (a, b, c) {
  arguments[2] = (typeof arguments).length;
  c > 10 ? console.log(c) : console.log(++c);
})(1, 2, 3);

Answer29. What's the output?

class Calculator {
  constructor(a, b) {
    this.a = a;
    this.b = b;
  }
  static getFlag() {
    return new Array(this.a).length == new Array(this.b).toString().length;
  }

  getValue() {
    return Calculator.getFlag() ? typeof this.a : typeof new Number(this.b);
  }
}

const me = new Calculator(5, 5);

console.log(me.getValue());
  • A: NaN
  • B: "string"
  • C: "object"
  • D: "number"
Answer
30. What's the output?
var name = "Auckland";

const nz = {
  name: "Kiwi",

  callMe: function () {
    return this.name;
  },
};

let me = nz.callMe;

let she = nz.callMe.bind(nz);

let result = me() === nz.callMe() ? she() : `${me()} ${she()}`;

console.log(result);
  • A: undefined
  • B: "Auckland"
  • C: "Kiwi"
  • D: "Auckland Kiwi"
Answer
31. What's the output?
const club = {
  name: "Juventus",
  player: ["Ronaldo"],
  showMePlayer: function () {
    this.player.map(function (thename) {
      console.log(this.name.length);
    }, this);
  },
  showMe: function () {
    this.player.forEach(
      function (thename) {
        console.log(this.name.length);
      }.bind(this)
    );
  },
  show: function () {
    const self = this;
    this.player.map(function (thename) {
      console.log(self.name.length);
    });
  },
  Me: function () {
    this.player.map(function (thename) {
      console.log(this.name.length);
    });
  },
};

club.showMePlayer();
club.showMe();
club.show();
club.Me();
  • A: 8 - 8 - 8 - 8
  • B: "Juventus" - "Juventus" - "Juventus" - "Juventus"
  • C: "Ronaldo" - "Ronaldo" - "Ronaldo" - "Ronaldo"
  • D: 8 - 8 - 8 - 0
Answer
32. What's the output?
((...a) => {
  const b = ["javascript", "new zealand"];

  const c = [...a, typeof a, ...b, "kiwi"];

  console.log(c.length + c[0].length);
})(new Array(10));

Answer33. What's the output?

function Kiora(name, ...career) {
  this.name = name;

  return Array.isArray(career) === true && typeof career === "object" ? {} : "";
}

var student = new Kiora("Vuong");

console.log(student.name);
  • A: "Vuong"
  • B: undefined
  • C: ErrorReference
  • D: false
Answer
34. What's the output?
class Filter {
  constructor(element) {
    this.element = element;
  }
  filter() {
    return this.type() === "object" ? this.element[0].name : "hello";
  }

  type() {
    return typeof this.element;
  }
}

let countries = [
  { name: "New Zealand", isdeveloped: true },
  { name: "Vietnam", isdeveloped: false },
];

let x = new Filter(countries);

const filter = countries.filter((item) => {
  return !item.isdeveloped;
});

console.log(x.filter().length + filter[0].name.length);

Answer35. What's the output?

async function abc() {
  console.log(8);

  await Promise.resolve(2).then(console.log);

  console.log(3);
}

setTimeout(() => {
  console.log(1);
}, 0);

abc();

queueMicrotask(() => {
  console.log(0);
});

Promise.resolve(4).then(console.log);

console.log(6);
  • A: 6 - 8 - 3 - 0 - 4 - 2 - 1
  • B: 8 - 2 - 3 - 0 - 4 - 6 - 1
  • C: 6 - 8 - 2 - 0 - 4 - 3 - 1
  • D: 8 - 6 - 2 - 0 - 4 - 3 - 1
Answer
  1) synchronous code
  2) microtask code (promise, queueMicrotask)
  3) macrotask code (setTimeout, setInterval)

36. What's the output?

function myAccount(money) {
  let myMoney = money;

  return {
    status: function () {
      return `You have $ ${myMoney} in your account`;
    },
    dePoSit: function (amount) {
      myMoney = myMoney + amount;
    },
    withDraw: function (amount) {
      if (amount > myMoney) {
        return `You cannot withdraw money now`;
      }
      myMoney = myMoney - amount;
    },
  };
}

const vuong = myAccount(1000);

vuong.withDraw(500);

vuong.withDraw(200);

vuong.dePoSit(100);

vuong.withDraw(50);

console.log(vuong.status());
  • A: "You have $ 950 in your account"
  • B: "You have $ 1000 in your account"
  • C: "You have $ 550 in your account"
  • D: "You have $ 350 in your account"
Answer37. What's the output?
const hoccoban = {
  x: "youtube.com/hoccoban".length,
  getMe() {
    const inner = function () {
      console.log(++this.x);
    };
    inner.bind(this)();
  },
};

hoccoban.getMe();

Answer38. What's the output?

function* hocCoBan() {
  yield "js.edu.vn";
  yield "youtube.com/hoccoban";
  yield "Vuong Nguyen";
}

let data = hocCoBan();

console.log((typeof data).length + data.next().value.length);
  • A: NaN
  • C: Error
Answer39. What's the output?
const a = [1, 2, "chó", 3, 1, "chó", "mèo", 3];

const b = [...new Set(a)];

b.length = "chó".length;

console.log(b);
  • B: [1, 2, "chó", 3, "mèo"]
  • C: [1, 2, "chó", "mèo"]
  • D: [1, 2, "chó"]
Answer40. What's the output?
const mot = function (m) {
  return arguments[0];
};

const hai = function (...m) {
  return arguments[arguments[0]];
};

const a = [mot(123), hai(1, 2, 3)];

console.log(typeof a !== "object" ? a[0] : a[1]);
  • D: 123
Answer41. What's the output?
class Component {
  constructor(age) {
    this.age = age + `${typeof Coder}`.length;
  }

  getAge() {
    return ++this.age;
  }
}

class Coder extends Component {
  constructor(age) {
    super(age);
    this.age = age - `${typeof Coder}`.length;
  }
}

const a = new Coder(16);

console.log(a.getAge());

Answer42. What's the output?

class RemoveFalse {
  constructor(element) {
    this.element = element;

    this.length = this.removeFalse().length;
  }

  removeFalse() {
    this.element = this.element.filter(Boolean);

    return this.element;
  }
}

const theArray = [true, false, 1, 0, NaN, undefined, "", null, "js.edu.vn"];

const a = new RemoveFalse(theArray);

console.log(a.length);
  • A: false
  • B: true
Answer43. What's the output?
const coderfarm = [1, [], {}, [], 2, 3];

const converted = Number(coderfarm instanceof Array);

const result = coderfarm.indexOf(converted + true);

console.log(result);

Answer44. What's the output?

const converter = (arrayInput) => {
  return { ...arrayInput };
};

const content = ["function", "object", "decorator"];

const checking = content[Number(false)];

const result = typeof converter(content) === content[1];

console.log(checking ? (result ? (typeof converter).length : false) : false);
  • B: NaN
  • C: true
Answer45. What's the output?
function* js(length) {
  for (let i = length.length; i > 0; --i) {
    yield i;
  }
}

let getJS = js(typeof js);

let result = getJS.next().value;

console.log(result + getJS.next().value);

Answer46. What's the output?

var ages = [10, 15, 20, 25];

let response = [];

ages.some(function (currentValue, index, ages) {
  if (currentValue > ages[ages.length - index])
    response.push(currentValue + ages.length);
});

console.log(response);
  • A: [20]
  • B: [20, 25]
  • C: [25, 29]
  • D: [29]
Answer47. What's the output?
const getSTring = (string, method = false) => {
  if (method === true) {
    return string.slice(1, 4).length;
  }

  return string.substr(1, 4).length;
};

console.log(getSTring("hello", true) + getSTring("hello"));

Answer48. What's the output?

(function (a, b, c) {
  console.log(Boolean([...arguments].slice(2, 3)[0].slice(3, 4)));
})("hello", "world", "new zealand");
  • A: "new"
  • B: true
  • C: "land"
  • D: false
Answer49. What's the output?
class HocCoBan {
  name = "hello world";

  getSlice(slice) {
    return this.getName(slice).slice(true, this.name.length);
  }

  getName(space) {
    return this.name.split(space);
  }
}

HocCoBan.prototype.split = function (argument) {
  return this.getSlice(argument);
};

const a = new HocCoBan();

console.log(a.split("").length);
  • A: NaN
  • B: true
Answer50. What's the output?
function javaScript(node) {
  let mot = node.includes("I") ? "love" : "you";

  return function (deno = mot) {
    let hai = node.replace(deno, "done");

    return function (done = hai) {
      return (node + deno + done).length;
    };
  };
}

console.log(javaScript("I love you")()());

Answer51. What's the output?

const www = ["hello", "coranovirus", "kiora", "world", "new zealand"];

const found = www.find(function (world) {
  return world > "victory";
});

const result = found[1] < www[0][0] ? www[false ? 1 : 0] : www[true ? 0 : 1];

console.log(result);
  • A: "hello"
  • B: "world"
  • C: "victory"
  • D: "w"
Answer52. What's the output?
(function (flag) {
  let age = Boolean(NaN === NaN ? false : flag);

  console.log(age.toString()[Number(flag)]);
})([]);
  • A: "f"
  • B: "t"
  • C: true
  • D: false
Answer53. What's the output?
1) console.log(Boolean([]));
2) console.log(Number([]));
3) console.log(Number(Boolean([])));
4) console.log(Boolean(Number([])));

5) console.log(Boolean({}));
6) console.log(Number({}));
7) console.log(Number(Boolean({})));
8) console.log(Boolean(Number({})));

9) console.log(Boolean(new Boolean(false)));
  • A: true - 0 - 1 - false - true - 1 - 1 - false - false
  • B: true - 0 - 1 - false - false - NaN - 1 - false - true
  • C: true - 0 - 1 - false - false - false - 1 - false - false
  • D: true - 0 - 1 - false - true - NaN - 1 - false - true
Answer54. What's the output?
const myYoutube = {
  name: "hoccoban",
  address: "youtube.com/hoccoban",
  getInfo() {
    return this;
  },
  content: () => (this === window ? myYoutube.getInfo() : this),
};

console.log(myYoutube.content().name);
  • A: "hoccoban"
  • B: window (object)
  • C: NaN
  • D: undefined
Answer55. What's the output?
const myArray = [1, 2, 3];

myArray.someProperty = this;

Array.prototype.someOtherProperty = "hello";

let result = [];

for (let key in myArray) {
  result.push(key);
}

for (let key in myArray) {
  if (myArray.hasOwnProperty(key)) {
    result.push(key);
  }
}

console.log(result.length);
  • B: NaN
Answer56. What's the output?
const coderfarm = [1, 2, 3, 4, 5];

const [top, ...bottom] = (function (a) {
  let result = a;

  a.unshift(new Array(3));

  return result;
})(coderfarm);

console.log(top.length + bottom.length);

Answer57. What's the output?

let age = { number: 10 };

const getAge = (flag) => {
  flag ? delete age.number : delete age;
  return age.number++;
};

console.log(getAge(false));

console.log(age.number);

console.log(getAge(true));

console.log(age.number);
  • A: 10 - 10 - NaN - NaN
  • B: 10 - 10 - undefined - undefined
  • C: 10 - 11 - undefined - undefined
  • D: 10 - 11 - NaN - NaN
Answer58. What's the output?
const youtube = { name: "hoccoban" };

const copy = Object.create(youtube);

const cloneA = Object.assign({}, copy);

const cloneB = Object.assign({}, youtube);

console.log(cloneA.name);

console.log(cloneB.name);

console.log(copy.name);
  • A: undefined - "hoccoban" - "hoccoban"
  • B: "hoccoban" - "hoccoban" - "hoccoban"
  • C: "hoccoban" - "hoccoban" - "undefined"
  • D: undefined - "undefined" - "hoccoban"
Answer59. What's the output?
((x) => {
  const data = !Array.isArray(x) ? x : x.entries();

  console.log(data.next().value[1]);
})(["hello", "world", "vuong"]);
  • A: NaN
  • B: "hello"
  • C: "world"
  • D: "vuong"
Answer60. What's the output?
let x = Symbol();

let y = Symbol();

console.log(x === y ? `${typeof x}`[1] : `${typeof x}`[2]);
  • A: NaN
  • B: "object"
  • C: "y"
  • D: "m"
Answer61. What's the output?
const frameworks = ["react", "angular", "vue"];

const iterator = frameworks[Symbol.iterator]();
const i = frameworks.entries();

iterator.next();
i.next();

console.log(iterator.next().value[1]);
console.log(i.next().value[1]);
  • A: "react" - "angular"
  • B: "react" - "react"
  • C: "angular" - "angular"
  • D: "n" - "angular"
Answer62. What's the output?
class React {
  theName = "Not React";
}

class Author extends React {
  static theName = "Real React";

  render() {
    return this.theName;
  }

  static render() {
    return this.theName;
  }
}

const me = new Author();

console.log(me.render());

console.log(Author.render());
  • A: "Not React" - "Real React"
  • B: "Not React" - Error
  • C: Error - Error
  • D: Error - "Real React"
Answer63. What's the output?
class js {
  say = "hello";
}

js.prototype.say = "goodbye";
console.log(new js().say);

js.prototype.thename = "google";
console.log(new js().thename);
  • A: Error - Error
  • B: "hello" - "google"
  • C: "goodbye" - "google"
  • D: Error - "google"
Answer64. What's the output?
const App = ([y, x, z]) => {			
	return ()=>{
			++x
		return ()=>{
			return x++;
		}
	}	
}

console.log(App([10, 20, 30, 40])()())

Answer65. What's the output?

const numbers = [5, 6, 7];

function callback(accumulator, currentValue){
	return accumulator + currentValue;
}

const theCallBack = (accumulator, currentValue) => accumulator + currentValue;

const sum = numbers.reduce(callback, numbers.reduce(theCallBack, numbers.reduce(theCallBack, 7)));

console.log(sum); 

Answer66. What's the output?

const a = {name: "hoccoban.com"};
const b = {name: "youtube.com/hoccoban"};

const first = {...a}.name.length;
const second = {...a, ...b}.name.length;
const third = {...a, ...b, name: "hello"}.name.length;

console.log(first + second + third)

Answer


About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK