hash = { :key => 'sym', 'key' => 'str' } p hash[:key] # => 'sym' p hash['key'] # => 'str' しかし、Railsの、例えばcontrollerなどで使われるparamsではこうはならない。SymbolとStringのどちらを指定しても同じ値が取得できる。 class SampleController < ApplicationController def index p params[:controller] # => 'sample' p params['controller'] # => 'sample' end end これはparamsがただのHashではなく、active_supportのHashWithIndifferentAccessクラスを継承したクラスであるため(ActionContro
A relevant ad will be displayed here soon. These ads help pay for my hosting. Please consider disabling your ad blocker on Pony Foo. These ads help pay for my hosting. Yo. Here’s another edition of ES6 – “I can’t believe they killed off Stringer Bell” – in Depth series. If you’ve never been around here before, start with A Brief History of ES6 Tooling. Then, make your way through destructuring, te
標準組み込みオブジェクトStringコンストラクターString() コンストラクター静的メソッドString.fromCharCode()String.fromCodePoint()String.raw()インスタンスメソッドString.prototype[@@iterator]()String.prototype.anchor() 非推奨 String.prototype.at()String.prototype.big() 非推奨 String.prototype.blink() 非推奨 String.prototype.bold() 非推奨 String.prototype.charAt()String.prototype.charCodeAt()String.prototype.codePointAt()String.prototype.concat()String.proto
CloudSearch使ってるのだけれども、トークナイズ辞書の仕様の所為かひらがなとカタカナでサジェスト時の候補返却内容が異なった。 候補のテキストフィールド自体はカタカナで、カタカナの方が意図する候補を返却していたので、JavaScriptでひらがな/カタカナに変換する方法を模索してみた。 後で加筆予定。 事前知識 Unicodeの各文字範囲 文字種別 Unicode Unicodeの示す文字範囲 全角ひらがな 0x3041 - 0x3096 ぁ, あ, ぃ, い, ... , ゕ, ゖ 全角カタカナ 0x30A1 - 0x30F6 ァ, ア, ィ, イ, ... , ヵ, ヶ 半角カタカナ 0xFF61 - 0xFF9F (順序が全角ひらがな/カタカナと異なる) 全角ひらがな → 全角カタカナは +0x60 全角カタカナ → 全角ひらがなは -0x60, JavaScriptでの文字操
How can I convert a string to a JavaScript array? Look at the code: var string = "0,1"; var array = [string]; alert(array[0]); In this case alert shows 0,1. If it where an array, it would show 0. And if alert(array[1]) is called, it should pop-up 1 Is there any chance to convert such string into a JavaScript array?
fromCharCode() は String の静的メソッドなので、自分で生成した String オブジェクトのメソッドではなく、常に String.fromCharCode() として使用するようにしてください。 Unicode のコードポイントは 0 から 1114111 (0x10FFFF) までの範囲です。charAt() は常に 65536 より小さい値を返しますが、これは上位のコードポイントは 16 ビットのサロゲート擬似文字のペアによって表されているからです。したがって、65535 より大きい値を持つ完全な文字を取得するには、charAt(i) だけでなく charAt(i + 1) も取得するか(2 つの文字を持つ文字列を操作する場合と同じです)、または codePointAt(i) と String.fromCodePoint() を使用する必要があります。Unicod
The blog post covers new features of strings in ECMAScript 6 (ES6). Unicode code point escapes # Unicode “characters” (code points) are 21 bit long [1]. JavaScript strings are (roughly) sequences of 16 bit characters, encoded as UTF-16. Therefore, code points beyond the first 16 bits of the code point range (the Basic Multilingual Pane, BMP) are represented by two JavaScript characters. Until now
Can I convert a string representing a boolean value (e.g., 'true', 'false') into an intrinsic type in JavaScript? I have a hidden form in HTML that is updated based on a user's selection within a list. This form contains some fields which represent boolean values and are dynamically populated with an intrinsic boolean value. However, once this value is placed into the hidden input field it becomes
標準組み込みオブジェクトStringコンストラクターString() コンストラクタープロパティString: lengthメソッドString.prototype[@@iterator]()String.prototype.anchor() 非推奨 String.prototype.at()String.prototype.big() 非推奨 String.prototype.blink() 非推奨 String.prototype.bold() 非推奨 String.prototype.charAt()String.prototype.charCodeAt()String.prototype.codePointAt()String.prototype.concat()String.prototype.endsWith()String.prototype.fixed() 非推奨 Stri
In my previous article on ES6 array methods, I introduced the new methods available in ECMAScript 6 that work with the Array type. In this tutorial, you’ll learn about new ES6 methods that work with strings: String.prototype.* We’ll develop several examples, and mention the polyfills available for them. Remember that if you want to polyfill them all using a single library, you can employ es6-shim
標準組み込みオブジェクトStringコンストラクターString() constructorプロパティString: lengthメソッドString.prototype[@@iterator]()String.prototype.anchor() 非推奨 String.prototype.at()String.prototype.big() 非推奨 String.prototype.blink() 非推奨 String.prototype.bold() 非推奨 String.prototype.charAt()String.prototype.charCodeAt()String.prototype.codePointAt()String.prototype.concat()String.prototype.endsWith()String.prototype.fixed() 非推奨 S
ES6になると、String.prototype.repeatのメソッドが追加されるわけだが、そのアルゴリズムとパフォーマンスを追ってみている。 ES6 String.prototype.repeat の仕様では以下の様な感じでシンプルな書き方をしている。 countが 0 より小さい、または 無限大である場合は RangeError count 0 ならば、空文字列 そうでない場合は、count回、文字列を繰り返して連結する 単純に実装すれば、以下の様な感じで済む。 String.prototype.repeat = function (count) { if (count < 0 || !Number.isFinite(count)) throw new RangeError(); var result = "", str = this; for (var i = 0; i < cou
リリース、障害情報などのサービスのお知らせ
最新の人気エントリーの配信
処理を実行中です
j次のブックマーク
k前のブックマーク
lあとで読む
eコメント一覧を開く
oページを開く