본문 바로가기
TIL/JavaScript

Object.keys( )

by koreashowme 2020. 1. 8.

function countNumberOfKeys(obj) {

return Object.keys(obj).length;

//return number of properties the given obj has using Object.keys( )

}

function countNumberOfKeys(obj){

var count = 0;

// if there are no keys, then it will automatically start at 0 and return count at 0

for (let key in obj){

count++;

}

return count;

}

'TIL > JavaScript' 카테고리의 다른 글

THIS, 5 patterns of Binding(window(parent), constructor, apply, call  (0) 2020.02.23
이니셜 전화번호부 만들기. reduce 함수 사용.  (0) 2020.01.14
push()  (0) 2020.01.08
push()  (0) 2020.01.08
split('') && Array.from && [...]  (0) 2020.01.08

comment