임이 자바 스크립트 코드의 조각을 이해할 수없는 사람이 나를 이해하는 것을 도울 수 있습니다.var some = [] [ 'forEach'] [ 'constructor'];
var some = []['forEach']['constructor'];
임이 자바 스크립트 코드의 조각을 이해할 수없는 사람이 나를 이해하는 것을 도울 수 있습니다.var some = [] [ 'forEach'] [ 'constructor'];
var some = []['forEach']['constructor'];
그것은 기본적으로 Array.prototype.forEach.constructor
와 같은 무엇 [].forEach.constructor
과 동일합니다.
는 여기를 분해하는 방법 :이 코드는 유용 할 이유를 묻는 경우
[]['forEach']['constructor'];
// Convert bracket property access notation to dot notation
[].forEach.constructor;
// `forEach` is a property of Array.prototype
Array.prototype.forEach.constructor;
// `forEach` is a function reference with a
// `constructor` property, due to `Function.prototype`
Function.prototype.constructor;
// `Constructor.prototype.constructor === Constructor`, generally
Function;
console.log(
[]['forEach']['constructor'] === Function //=> true
);
, 내가 아주 확실하지 않다. 아마도 난독 화.
대괄호 표기법을 사용합니다. – Li357
[[Array # forEach']의 생성자를 얻습니다 (https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/forEach) –