var a = [ 'hello', 'world']; Console.log (타입 A); // Object Console.log (a.toString ()); // Hello, Word String Console.log (Object.Prototype.toString.call (a)); // [객체 배열] var b = { 'hello': 'world'}; Console.log (typeof b); // Object Console.log (b.toString ()); // [Object Object] console.log (Object.Prototype.tostring.call (b)); // [Object Object] console.log (Object.Prototype.tostring.call (b)); // [객체 개체]1. 배열 및 객체 유형은 두 결과 모두 객체입니다.
2. TOSTRING () 배열의 결과는 실제 문자열이고 객체의 결과는 고정되어 있습니다 [개체 객체]
3. Object.prototype.toString 호출을 통해 배열의 결과는 고정 된 [객체 배열]를 반환하고 객체의 결과는 여전히 [개체 객체]입니다.
ES2005 새로운 방법
Console.log (Array.isArray (a)); // trueconsole.log (Array.isArray (b)); // 거짓
위의 기사는 배열의 구현 방법과 JS의 객체를 판단하는 기사는 내가 공유 한 모든 컨텐츠입니다. 나는 당신이 당신에게 참조를 줄 수 있기를 바랍니다. 그리고 당신이 wulin.com을 더 지원할 수 있기를 바랍니다.