Showing posts from January 5, 2014

JavaScript: never use 「delete」 to remove element in array

Note: splice is the general way to add/remove elements. You should never use 「delete」 to remove elements in a array, because that creates a sparse array.// example of how delete creates a sparse array varaa = ["a", "b", "c"]; delete aa[1]; console.log(aa); // [ 'a', , 'c' ] console.log(aa.length); // 3see JavaScript Array Methods

where is client library at?

decidedly frustrated with me detail the issues.first, there's no clear indication what it's supposed to be. Sure, it's clear it's a lib on top of WebSocket protocol, with added feature that if browser doesn't support WebSocket, it'll automatically use other means (aka transports) such going thru Flash, XMLHttpRequest, hidden iframe, etc.but, Does it require Node.js? There's a server and client part. How are they related?the home page is extremely simple, but those simple examples hide a confuse ball. Nowhere it tells you it's relation to Node.js, or how server/client are related, or independent. And its FAQ, or its github pages, don't say neither. (instead, it has one hundred other links, none of which answers)Answer: is 2 JavaScript libs, socket server and socket client. But also, it is a protocol, on top of WebSocket. So, other langs can implement it too without using Node.js or JavaScript.Answer: has socket se…

mixed Chinese and English writing and punctuation

当写英中混合时,发现,英中标点符号混杂,没办法讲定规。要不就一率用英文式或一率用中文式。When writing mixed Chinese and English, i realized that, it's hard to have a uniform rule for using English punctuation or Chinese punctuation. Perhaps, a solution is then to always use English punctuation, or all Chinese punctuation.Intro to Chinese Punctuation for English SpeakersUnicode Full-Width CharactersUnicode: Punctuation & Printer's Symbols † ¶ © ® ™ ☙Emacs Lisp: Convert Punctuation Between English/Chinese FormsShould You Type Space After Comma? and Tiny Space Bar on Japanese KeyboardsEmacs Chinese Input for Studying Chinese