Object에 있는 key값을 배열에 담아주는 역할을 하는 함수

/**
 * Object key to array
 *
 * @Param {Object} obj
 * @return {Array}
 */
function objectKeyToArray(obj)
{
	var result = [];
	for (var k in obj)
	{
		result.push(k);
	}
	return result;
}

다음과 같이 키를 빼올 수 있다.

let keys = Object.keys({ apple: 'red', banana: 'yellow' });

메타데이터

조회수
828
좋아요
0

0개의 댓글

등록된 댓글이 없습니다.