Last active
August 29, 2015 14:06
-
-
Save tyage/cb52a67acedcf18d0d47 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// String.raw | |
console.log(`foo\n`) // foo | |
console.log(String.raw`foo\n`) // foo\n | |
console.log(`foo\n`.length) // 4 | |
console.log(String.raw`foo\n`.length) // 5 | |
console.log(String.raw`foo${1+2}`) // foo3 | |
console.log(`\x31`) // 1 | |
console.log(String.raw`\x31`) // \x31 | |
console.log(String.raw({ raw: ["a", "b", "c"] }, 0, 1, 2, 3)) // => a0b1c | |
// String.fromCodePrint, String.prototype.codePointAt | |
// 🍣 is d83c df63 | |
var utf16Sushi = Math.pow(2, 16) + (0xd83c - 0xd800) * Math.pow(2, 10) + (0xdf63 - 0xdc00) | |
console.log(utf16Sushi.toString(16)) // => 0x1f363 | |
console.log(String.fromCodePoint(utf16Sushi)) // => "🍣" | |
console.log("🍣".codePointAt(0).toString(16)) // => 0x1f363 | |
console.log("🍣".codePointAt(1).toString(16)) // => 0xdf63 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment