概要
メモです。
適宜追記する予定。
コメント欄に記載頂くと記事に反映します。
内容
String.prototype.includes
2020/01/22(Wed)
日本語版
https://developer.mozilla.org/ja/docs/Web/JavaScript/Reference/Global_Objects/String/includes
if (!String.prototype.includes) {
String.prototype.includes = function(search, start) {
'use strict';
if (typeof start !== 'number') {
start = 0;
}
if (start + search.length > this.length) {
return false;
} else {
return this.indexOf(search, start) !== -1;
}
};
}
英語版
https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/includes
if (!String.prototype.includes) {
String.prototype.includes = function(search, start) {
'use strict';
if (search instanceof RegExp) {
throw TypeError('first argument must not be a RegExp');
}
if (start === undefined) { start = 0; }
return this.indexOf(search, start) !== -1;
};
}
Polyfill のコードが違っていて、WSH環境で実行すると、日本語版だと文字列.includes(null)
や文字列.includes(undefined)
で、エラーになる。英語版のPolyfillだと、戻り値falseになって正常に動作する。
追記:2020/01/23(Thu) 00:33:すでに修正されていました。
Object.defineProperty()
2020/01/23(Thu) 00:43
日本語版
Object.defineProperty() - JavaScript | MDN
https://developer.mozilla.org/ja/docs/Web/JavaScript/Reference/Global_Objects/Object/defineProperty
英語版
Object.defineProperty() - JavaScript | MDN
https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/defineProperty
英語版には「Compatibility notes」に「Chrome 37」の項目があるが
日本語版の「互換性のメモ」欄にはない。
Array.prototype.indexOf()
2020/01/23(Thu) 00:53
日本語版
Array.prototype.indexOf() - JavaScript | MDN
https://developer.mozilla.org/ja/docs/Web/JavaScript/Reference/Global_Objects/Array/indexOf
英語版
Array.prototype.indexOf() - JavaScript | MDN
https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/indexOf
英語版には「Specifications」が1つしかない(2つ削除されている)、日本語版には3つある。
Object.defineProperty()でも、「Specifications」欄が同じようになっている。
全体の方針なのだろうか。
getUTCDate() の内容が getUTCDay() の本文
まさかのズレ。
日本語版
Date.prototype.getUTCDate() - JavaScript | MDN
https://developer.mozilla.org/ja/docs/Web/JavaScript/Reference/Global_Objects/Date/getUTCDate
終わりに
探せばいろいろみつかる気がします。
ログインしたら自分で更新もできるみたいなので、ご自身で更新して内容提案してみてはいかがでしょうか。
スクリーンショット撮るのはめんどいね。
→ スクリーンショット、Windows なら、Win + Shift + S で任意位置選択コピーで、Qiita記事上でペーストができてめちゃくちゃ便利でした。