Skip to content

Instantly share code, notes, and snippets.

@ENvironmentSet
Last active January 30, 2019 23:04
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ENvironmentSet/0f841fbaa5115a9675a26b33917224ed to your computer and use it in GitHub Desktop.
Save ENvironmentSet/0f841fbaa5115a9675a26b33917224ed to your computer and use it in GitHub Desktop.
You don't know arguments object
function problem1(a, b, c) {
  arguments[0] = 100;
  return [a, b, c];
}

problem1(1, 2, 3) // 반환값을 맞추어 보세요!

정답: [100, 2, 3]

function problem2(a, b, c) {
  delete arguments[0];
  arguments[0] = 100;
  return [a, b, c];
}

problem2(1, 2, 3) // 반환값을 맞추어 보세요!

정답: [1, 2, 3]

function problem3(a, b, c) {
  return Object.hasOwnProperty(arguments, 0);
}

problem3(1, 2, 3) // 반환값을 맞추어 보세요!

정답: false

function problem4(a, b, c = 10) {
  arguments[0] = 100;
  return [a, b, c];
}

problem4(1, 2) // 반환값을 맞추어 보세요!

정답: [1, 2, 10]

function problem5(a, b, c = 10) {
  return arguments.callee;
}

problem5(1, 2) // 반환값을 맞추어 보세요!

정답: 반환값 없음(TypeError)

function problem6() {
  arguments[2] = 3;
  return Array.prototype.slice.call(arguments);
}

problem6(1, 2); // 반환값을 맞추어 보세요!

정답: [1, 2]

function problem7() {
  return arguments.caller;
}

problem7(1); // 반환값을 맞추어 보세요!

정답: 비표준이므로 답을 내릴 수 없음

정답 해설: comming soon.. (블로그에 글 올릴 예정입니다~) --> https://environmentset.github.io/

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment