JSFiddle - React, Tailwind, and code Playground
HTML
<script src="https://raw.github.com/gist/816688/6b983e783f59b57c5293d2fd471be4f6f065c9d2/print.js"></script>
<ul>
<li><a href="http://es5.github.com/#x15.2.3.6">15.2.3.6 Object.defineProperty ( O, P, Attributes ) - - Annotated ES5</a></li>
<li><a href="http://es5.github.com/#x8.10.5">8.10.5 ToPropertyDescriptor - Annotated ES5</a></li>
<li><a href="https://developer.mozilla.org/en/JavaScript/Reference/Global_Objects/Object/defineProperty">defineProperty - MDN Docs</a></li>
<li><a href="http://hibari.2ch.net/test/read.cgi/hp/1308664388/924n-">+ JavaScript の質問用スレッド vol.88 +</a></li>
</ul>
<div id="Print"></div>
CSS
#Print { margin: 1em 0; padding: 0.5em; border: 1px solid #999; color: black; background-color: #EFEFEF; font-family: monospace; }
JavaScript
/**
* undefined-test.js
* @version 1.0.3
* @auther think49
*/
/**
* 関数コード
*/
(function () {
var undefined; // ローカル変数 undefined でグローバル変数を上書きする
undefined = 1; // 1 (書き換え可能)
print(undefined); // 1
})();
/**
* グローバルコード
*/
undefined = 1;
if (typeof undefined !== 'undefined') {
if (typeof Object.defineProperty === 'function') {
Object.defineProperty(this, 'undefined', {value: void 0, writable: false, enumerable: false}); // [[Writable]]: false, [[Enumerable]]: false
} else {
undefined = void 0;
}
}
undefined = 1;
print(undefined);