242. Valid Anagram

https://leetcode.com/problems/valid-anagram/description/

var isAnagram = function(s, t) {
    if(s.length !== t.length) return false;
    
    const sMap = {};
    const tMap = {};

    (...s).forEach(key => sMap(key) = (sMap(key) || 0) + 1 );
    (...t).forEach(key => tMap(key) = (tMap(key) || 0) + 1 );

    for(let sKey of Object.keys(sMap)) {
        if(!tMap(sKey)) {
            return false;
        }
        if(tMap(sKey) !== sMap(sKey)) {
            return false;
        }
    }

    return true;

};

개체에 키 값이 있는지 확인하고 초기화하는 코드가 마음에 듭니다.