Created
July 5, 2016 05:41
-
-
Save jnvm/e1801b7e62d6d7b1ae8efe1da5546295 to your computer and use it in GitHub Desktop.
live-test & show valid starting identifier characters in js.
This file contains 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
+function ShowValidStartingIdentifierChars(){ | |
var validStarters={} | |
,max=130000 | |
,group=5000 | |
for(var i=0;i<max;i++){ | |
try{ | |
var s=String.fromCodePoint(i) | |
eval(`let ${s}=1`) | |
validStarters[s]=1 | |
} | |
catch(e){ } | |
} | |
var st=document.createElement("style") | |
st.innerHTML=` | |
span { | |
display: inline-block; | |
outline: solid #000 1px; | |
padding: .25em; | |
font-size: 2em; | |
background-color:#fff; | |
transition:transform ease-in .0625s; | |
} | |
span:hover{ | |
transform:scale(2); | |
} | |
` | |
document.body.appendChild(st) | |
var d | |
Object.keys(validStarters).forEach((x,i)=>{ | |
if( !(i%group) ){ | |
if(d) document.body.appendChild(d) | |
d=document.createElement("details") | |
d.innerHTML=`<summary>${i} - ${i+group}` | |
} | |
var s=document.createElement("span") | |
s.innerHTML=x | |
s.setAttribute("title",x.codePointAt(0)) | |
d.appendChild(s) | |
}) | |
}() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment