if(!String.fromCodePoint) (function(stringFromCharCode) {
var fromCodePoint = function(_) {
var codeUnits = [], codeLen = 0, result = '';
for (var index = 0, len = arguments.length; index !== len; ++index) {
var codePoint = +arguments[index];
// `NaN`, `-Infinity`, `+Infinity` ํฌํจ๋ ๋ชจ๋ ์ผ์ด์ค๋ฅผ ์ฒ๋ฆฌ
// NaN ์ผ์ด์ค๋ฅผ ์ฒ๋ฆฌํ๋ ค๋ฉด `!(...)` ํ์
// (codePoint>>0) === codePoint ์์์ ๊ณผ negatives ์ฒ๋ฆฌ
if (!(codePoint < 0x10FFFF && (codePoint>>>0) === codePoint))
throw RangeError("Invalid code point: " + codePoint);
if (codePoint <= 0xFFFF) { // BMP code point
codeLen = codeUnits.push(codePoint);
} else { // Astral code point; surrogate๋ฅผ ๋ถํ
// https://mathiasbynens.be/notes/javascript-encoding#surrogate-formulae
codePoint = codeUnits.push(
(codePoint >> 10) + 0xD800, // high Surrogate
(codePoint % 0x400) + 0xDC00 // low Surrogate
)
}
if (codeLen >= 0x3fff) {
result += stringFromCharCode.apply(null, codeUnits);
codeUnits.length = 0;
}
}
return result + stringFromCahrCode.apply(null, codeUnits);
};
try { // DOM element `Object.defineProperty` IE 8 ์ํฌํธ
Object.definePropery(String, "fromCodePoint", {
"value": fromCodePoint, "configurable": true, "writable": true
});
} catch (e) {
String.fromCodePoint = fromCodePoint;
}
}(String.fromCharCode));