<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>JavaScript | You Look Too Cool</title>
	<atom:link href="https://stabucky.com/wp/archives/category/digital/javascript/feed" rel="self" type="application/rss+xml" />
	<link>https://stabucky.com/wp</link>
	<description>ゆるくつくる stabuckyのブログ</description>
	<lastBuildDate>Sun, 14 Sep 2025 13:44:44 +0000</lastBuildDate>
	<language>ja</language>
	<sy:updatePeriod>
	hourly	</sy:updatePeriod>
	<sy:updateFrequency>
	1	</sy:updateFrequency>
	<generator>https://wordpress.org/?v=6.9.4</generator>

<image>
	<url>https://stabucky.com/wp/wp-content/uploads/2024/05/cropped-stabucky-32x32.png</url>
	<title>JavaScript | You Look Too Cool</title>
	<link>https://stabucky.com/wp</link>
	<width>32</width>
	<height>32</height>
</image> 
	<item>
		<title>TRILLニュースを非表示にするブックマークレット</title>
		<link>https://stabucky.com/wp/archives/20387</link>
					<comments>https://stabucky.com/wp/archives/20387#respond</comments>
		
		<dc:creator><![CDATA[stabucky]]></dc:creator>
		<pubDate>Thu, 14 Aug 2025 15:05:30 +0000</pubDate>
				<category><![CDATA[JavaScript]]></category>
		<category><![CDATA[ブックマークレット]]></category>
		<guid isPermaLink="false">https://stabucky.com/wp/?p=20387</guid>

					<description><![CDATA[Yahoo! JAPANに表示される「TRILL ニュース」という記事が鬱陶しいです。 「クイズ形式でご紹介します！」ってやかましいわ。 目次 コード設定方法使用方法 コード javascript:(function() [&#8230;]]]></description>
										<content:encoded><![CDATA[<p>Yahoo! JAPANに表示される「TRILL ニュース」という記事が鬱陶しいです。<br />
「クイズ形式でご紹介します！」ってやかましいわ。</p>

  <div id="toc" class="toc tnt-number toc-center tnt-number border-element"><input type="checkbox" class="toc-checkbox" id="toc-checkbox-2" checked><label class="toc-title" for="toc-checkbox-2">目次</label>
    <div class="toc-content">
    <ol class="toc-list open"><li><a href="#toc1" tabindex="0">コード</a></li><li><a href="#toc2" tabindex="0">設定方法</a></li><li><a href="#toc3" tabindex="0">使用方法</a></li></ol>
    </div>
  </div>

<h2><span id="toc1">コード</span></h2>
<div class="codecolorer-container text dawn" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:400px;"><div class="text codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap;">javascript:(function() {<br />
&nbsp; const cites = document.querySelectorAll('cite');<br />
&nbsp; cites.forEach(cite =&gt; {<br />
&nbsp; &nbsp; if (cite.textContent.includes('TRILL ニュース')) {<br />
&nbsp; &nbsp; &nbsp; let parentArticle = cite.closest('article');<br />
&nbsp; &nbsp; &nbsp; if (parentArticle) {<br />
&nbsp; &nbsp; &nbsp; &nbsp; parentArticle.style.display = 'none';<br />
&nbsp; &nbsp; &nbsp; }<br />
&nbsp; &nbsp; }<br />
&nbsp; });<br />
})();</div></div>
<h2><span id="toc2">設定方法</span></h2>
<p>適当なブックマークを作ります。<br />
右クリックから編集を選択し上のコードをコピペします。<br />
保存をクリックします。</p>
<h2><span id="toc3">使用方法</span></h2>
<p>Yahoo! JAPAN開きます。<br />
先程のブックマークを選択（クリック）します。<br />
「TRILL ニュース」を含む記事が非表示になります。</p>
<p>実行前<br />
<img fetchpriority="high" decoding="async" src="https://stabucky.com/wp/wp-content/uploads/2025/08/before.png" alt="" width="440" height="476" class="alignnone size-full wp-image-20388" /></p>
<p>実行後<br />
<img decoding="async" src="https://stabucky.com/wp/wp-content/uploads/2025/08/after.png" alt="" width="440" height="217" class="alignnone size-full wp-image-20389" /></p>
]]></content:encoded>
					
					<wfw:commentRss>https://stabucky.com/wp/archives/20387/feed</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
		<item>
		<title>Three.js入門</title>
		<link>https://stabucky.com/wp/archives/19300</link>
					<comments>https://stabucky.com/wp/archives/19300#respond</comments>
		
		<dc:creator><![CDATA[stabucky]]></dc:creator>
		<pubDate>Sat, 18 Jan 2025 08:45:43 +0000</pubDate>
				<category><![CDATA[JavaScript]]></category>
		<category><![CDATA[three.js]]></category>
		<category><![CDATA[入門]]></category>
		<guid isPermaLink="false">https://stabucky.com/wp/?p=19300</guid>

					<description><![CDATA[目次 基本全体座標立体の設定直方体球体円錐直線 基本 全体 JavaScriptを含むHTML全体は次のコードのとおりです。 モジュールはCDNを使っているのであらかじめダウンロードする必要はありません。 スクリプトは次 [&#8230;]]]></description>
										<content:encoded><![CDATA[
  <div id="toc" class="toc tnt-number toc-center tnt-number border-element"><input type="checkbox" class="toc-checkbox" id="toc-checkbox-4" checked><label class="toc-title" for="toc-checkbox-4">目次</label>
    <div class="toc-content">
    <ol class="toc-list open"><li><a href="#toc1" tabindex="0">基本</a><ol><li><a href="#toc2" tabindex="0">全体</a></li><li><a href="#toc3" tabindex="0">座標</a></li></ol></li><li><a href="#toc4" tabindex="0">立体の設定</a><ol><li><a href="#toc5" tabindex="0">直方体</a></li><li><a href="#toc6" tabindex="0">球体</a></li><li><a href="#toc7" tabindex="0">円錐</a></li><li><a href="#toc8" tabindex="0">直線</a></li></ol></li></ol>
    </div>
  </div>

<h2><span id="toc1">基本</span></h2>
<h3><span id="toc2">全体</span></h3>
<p>JavaScriptを含むHTML全体は次のコードのとおりです。<br />
モジュールはCDNを使っているのであらかじめダウンロードする必要はありません。<br />
スクリプトは次のとおりですが順番は厳密ではありません。最後に描画をセットします。</p>
<ul>
<li>シーンの設定</li>
<li>カメラの設定</li>
<li>レンダラーの設定</li>
<li>ライトの設定</li>
<li>立体の設定</li>
<li>描画</li>
</ul>
<div class="codecolorer-container javascript dawn" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:400px;"><div class="javascript codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap;"><span style="color: #339933;">&lt;</span>html<span style="color: #339933;">&gt;</span><br />
<span style="color: #339933;">&lt;</span>body<span style="color: #339933;">&gt;</span><br />
<span style="color: #339933;">&lt;</span>script type<span style="color: #339933;">=</span><span style="color: #3366CC;">&quot;module&quot;</span><span style="color: #339933;">&gt;</span><br />
<span style="color: #FF0000;">import</span> <span style="color: #339933;">*</span> as THREE from <span style="color: #3366CC;">&quot;https://cdn.jsdelivr.net/npm/three/build/three.module.js&quot;</span><span style="color: #339933;">;</span><br />
<br />
<span style="color: #006600; font-style: italic;">// シーンの設定</span><br />
<span style="color: #000066; font-weight: bold;">const</span> scene <span style="color: #339933;">=</span> <span style="color: #000066; font-weight: bold;">new</span> THREE.<span style="color: #660066;">Scene</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
<br />
<span style="color: #006600; font-style: italic;">// カメラの設定</span><br />
<span style="color: #000066; font-weight: bold;">const</span> camera <span style="color: #339933;">=</span> <span style="color: #000066; font-weight: bold;">new</span> THREE.<span style="color: #660066;">PerspectiveCamera</span><span style="color: #009900;">&#40;</span><br />
<span style="color: #CC0000;">60</span><span style="color: #339933;">,</span><br />
window.<span style="color: #660066;">innerWidth</span> <span style="color: #339933;">/</span> window.<span style="color: #660066;">innerHeight</span><br />
<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
camera.<span style="color: #660066;">position</span>.<span style="color: #000066; font-weight: bold;">set</span><span style="color: #009900;">&#40;</span><span style="color: #CC0000;">50</span><span style="color: #339933;">,</span> <span style="color: #CC0000;">50</span><span style="color: #339933;">,</span> <span style="color: #CC0000;">100</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
camera.<span style="color: #660066;">lookAt</span><span style="color: #009900;">&#40;</span><span style="color: #CC0000;">0</span><span style="color: #339933;">,</span> <span style="color: #CC0000;">0</span><span style="color: #339933;">,</span> <span style="color: #CC0000;">0</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
<br />
<span style="color: #006600; font-style: italic;">// レンダラーの設定</span><br />
<span style="color: #000066; font-weight: bold;">const</span> renderer <span style="color: #339933;">=</span> <span style="color: #000066; font-weight: bold;">new</span> THREE.<span style="color: #660066;">WebGLRenderer</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
renderer.<span style="color: #660066;">setSize</span><span style="color: #009900;">&#40;</span>window.<span style="color: #660066;">innerWidth</span><span style="color: #339933;">,</span> window.<span style="color: #660066;">innerHeight</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
document.<span style="color: #660066;">body</span>.<span style="color: #660066;">appendChild</span><span style="color: #009900;">&#40;</span>renderer.<span style="color: #660066;">domElement</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
<br />
<span style="color: #006600; font-style: italic;">// ライトの設定</span><br />
<span style="color: #000066; font-weight: bold;">const</span> directionalLight <span style="color: #339933;">=</span> <span style="color: #000066; font-weight: bold;">new</span> THREE.<span style="color: #660066;">DirectionalLight</span><span style="color: #009900;">&#40;</span>0xffffff<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
directionalLight.<span style="color: #660066;">position</span>.<span style="color: #000066; font-weight: bold;">set</span><span style="color: #009900;">&#40;</span><span style="color: #CC0000;">120</span><span style="color: #339933;">,</span> <span style="color: #CC0000;">150</span><span style="color: #339933;">,</span> <span style="color: #CC0000;">100</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
scene.<span style="color: #660066;">add</span><span style="color: #009900;">&#40;</span>directionalLight<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
<br />
<span style="color: #006600; font-style: italic;">// ----立体の設定 ここから----</span><br />
<span style="color: #006600; font-style: italic;">// 直方体</span><br />
<span style="color: #000066; font-weight: bold;">const</span> boxGeometry <span style="color: #339933;">=</span> <span style="color: #000066; font-weight: bold;">new</span> THREE.<span style="color: #660066;">BoxGeometry</span><span style="color: #009900;">&#40;</span><span style="color: #CC0000;">10</span><span style="color: #339933;">,</span> <span style="color: #CC0000;">20</span><span style="color: #339933;">,</span> <span style="color: #CC0000;">30</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
<span style="color: #000066; font-weight: bold;">const</span> boxMaterial <span style="color: #339933;">=</span> <span style="color: #000066; font-weight: bold;">new</span> THREE.<span style="color: #660066;">MeshStandardMaterial</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#123;</span><br />
color<span style="color: #339933;">:</span> 0x00ff00<span style="color: #339933;">,</span><br />
<span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
<span style="color: #000066; font-weight: bold;">const</span> box <span style="color: #339933;">=</span> <span style="color: #000066; font-weight: bold;">new</span> THREE.<span style="color: #660066;">Mesh</span><span style="color: #009900;">&#40;</span>boxGeometry<span style="color: #339933;">,</span> boxMaterial<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
box.<span style="color: #660066;">position</span>.<span style="color: #000066; font-weight: bold;">set</span><span style="color: #009900;">&#40;</span><span style="color: #CC0000;">0</span><span style="color: #339933;">,</span> <span style="color: #CC0000;">0</span><span style="color: #339933;">,</span> <span style="color: #CC0000;">0</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
scene.<span style="color: #660066;">add</span><span style="color: #009900;">&#40;</span>box<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
<span style="color: #006600; font-style: italic;">// ----立体の設定 ここまで----</span><br />
<br />
<span style="color: #006600; font-style: italic;">// 描画</span><br />
renderer.<span style="color: #660066;">render</span><span style="color: #009900;">&#40;</span>scene<span style="color: #339933;">,</span> camera<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
<span style="color: #339933;">&lt;/</span>script<span style="color: #339933;">&gt;</span><br />
<span style="color: #339933;">&lt;/</span>body<span style="color: #339933;">&gt;</span><br />
<span style="color: #339933;">&lt;/</span>html<span style="color: #339933;">&gt;</span></div></div>
<p>結果<br />
<img decoding="async" src="https://stabucky.com/wp/wp-content/uploads/2025/01/basic.png" alt="" width="400" height="400" class="aligncenter size-full wp-image-19301" srcset="https://stabucky.com/wp/wp-content/uploads/2025/01/basic.png 400w, https://stabucky.com/wp/wp-content/uploads/2025/01/basic-150x150.png 150w" sizes="(max-width: 400px) 100vw, 400px" /></p>
<p><a href="https://stabucky.com/wp/wp-content/uploads/2025/01/basic.html">サンプルファイル</a></p>
<h3><span id="toc3">座標</span></h3>
<p>座標は右にX、上にY、手前にZとなっています。</p>
<p><img loading="lazy" decoding="async" src="https://stabucky.com/wp/wp-content/uploads/2025/01/xyz.png" alt="" width="365" height="343" class="aligncenter size-full wp-image-19308" /></p>
<h2><span id="toc4">立体の設定</span></h2>
<p>サンプルの「立体の設定」のところを書き換えます。<br />
直方体や球体などの、形をgeometryで、材料（表面）をmaterialで設定します。</p>
<h3><span id="toc5">直方体</span></h3>
<p>大きさ（辺の長さ）はBoxGeometry(X, Y, Z)とします。<br />
位置はposition.set(X, Y, Z)とします。直方体のど真ん中がここになります。角（頂点）ではありません。<br />
色はMeshStandardMaterial({color: color: 0xカラーコード})とします。カラーコードはRGBをそれぞれ2桁の16進数で表します。</p>
<div class="codecolorer-container javascript dawn" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:400px;"><div class="javascript codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap;"><span style="color: #006600; font-style: italic;">// 直方体</span><br />
<span style="color: #000066; font-weight: bold;">const</span> boxGeometry <span style="color: #339933;">=</span> <span style="color: #000066; font-weight: bold;">new</span> THREE.<span style="color: #660066;">BoxGeometry</span><span style="color: #009900;">&#40;</span><span style="color: #CC0000;">10</span><span style="color: #339933;">,</span> <span style="color: #CC0000;">20</span><span style="color: #339933;">,</span> <span style="color: #CC0000;">30</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
<span style="color: #000066; font-weight: bold;">const</span> boxMaterial <span style="color: #339933;">=</span> <span style="color: #000066; font-weight: bold;">new</span> THREE.<span style="color: #660066;">MeshStandardMaterial</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#123;</span><br />
color<span style="color: #339933;">:</span> 0x00ff00<span style="color: #339933;">,</span><br />
<span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
<span style="color: #000066; font-weight: bold;">const</span> box <span style="color: #339933;">=</span> <span style="color: #000066; font-weight: bold;">new</span> THREE.<span style="color: #660066;">Mesh</span><span style="color: #009900;">&#40;</span>boxGeometry<span style="color: #339933;">,</span> boxMaterial<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
box.<span style="color: #660066;">position</span>.<span style="color: #000066; font-weight: bold;">set</span><span style="color: #009900;">&#40;</span><span style="color: #CC0000;">0</span><span style="color: #339933;">,</span> <span style="color: #CC0000;">0</span><span style="color: #339933;">,</span> <span style="color: #CC0000;">0</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
scene.<span style="color: #660066;">add</span><span style="color: #009900;">&#40;</span>box<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></div></div>
<h3><span id="toc6">球体</span></h3>
<p>SphereGeometry(半径, 幅の分割数, 高さの分割数)とします。分割数は32としているケースが多いようです。</p>
<div class="codecolorer-container javascript dawn" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:400px;"><div class="javascript codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap;"><span style="color: #006600; font-style: italic;">// 球体</span><br />
<span style="color: #000066; font-weight: bold;">const</span> ballGeometry <span style="color: #339933;">=</span> <span style="color: #000066; font-weight: bold;">new</span> THREE.<span style="color: #660066;">SphereGeometry</span><span style="color: #009900;">&#40;</span><span style="color: #CC0000;">10</span><span style="color: #339933;">,</span> <span style="color: #CC0000;">32</span><span style="color: #339933;">,</span> <span style="color: #CC0000;">32</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
<span style="color: #000066; font-weight: bold;">const</span> ballMaterial <span style="color: #339933;">=</span> <span style="color: #000066; font-weight: bold;">new</span> THREE.<span style="color: #660066;">MeshStandardMaterial</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#123;</span><br />
color<span style="color: #339933;">:</span> 0xff0000<span style="color: #339933;">,</span><br />
<span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
<span style="color: #000066; font-weight: bold;">const</span> ball <span style="color: #339933;">=</span> <span style="color: #000066; font-weight: bold;">new</span> THREE.<span style="color: #660066;">Mesh</span><span style="color: #009900;">&#40;</span>ballGeometry<span style="color: #339933;">,</span> ballMaterial<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
ball.<span style="color: #660066;">position</span>.<span style="color: #000066; font-weight: bold;">set</span><span style="color: #009900;">&#40;</span><span style="color: #CC0000;">0</span><span style="color: #339933;">,</span> <span style="color: #CC0000;">0</span><span style="color: #339933;">,</span> <span style="color: #CC0000;">0</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
scene.<span style="color: #660066;">add</span><span style="color: #009900;">&#40;</span>ball<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></div></div>
<h3><span id="toc7">円錐</span></h3>
<p>ConeGeometry(半径, 高さ, 分割数)とします。</p>
<div class="codecolorer-container javascript dawn" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:400px;"><div class="javascript codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap;"><span style="color: #006600; font-style: italic;">// 円錐</span><br />
<span style="color: #000066; font-weight: bold;">const</span> coneGeometry <span style="color: #339933;">=</span> <span style="color: #000066; font-weight: bold;">new</span> THREE.<span style="color: #660066;">ConeGeometry</span><span style="color: #009900;">&#40;</span><span style="color: #CC0000;">10</span><span style="color: #339933;">,</span> <span style="color: #CC0000;">20</span><span style="color: #339933;">,</span> <span style="color: #CC0000;">32</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
<span style="color: #000066; font-weight: bold;">const</span> coneMaterial <span style="color: #339933;">=</span> <span style="color: #000066; font-weight: bold;">new</span> THREE.<span style="color: #660066;">MeshStandardMaterial</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#123;</span><br />
color<span style="color: #339933;">:</span> 0x0000ff<span style="color: #339933;">,</span><br />
<span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
<span style="color: #000066; font-weight: bold;">const</span> cone <span style="color: #339933;">=</span> <span style="color: #000066; font-weight: bold;">new</span> THREE.<span style="color: #660066;">Mesh</span><span style="color: #009900;">&#40;</span>coneGeometry<span style="color: #339933;">,</span> coneMaterial<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
cone.<span style="color: #660066;">position</span>.<span style="color: #000066; font-weight: bold;">set</span><span style="color: #009900;">&#40;</span><span style="color: #CC0000;">0</span><span style="color: #339933;">,</span> <span style="color: #CC0000;">0</span><span style="color: #339933;">,</span> <span style="color: #CC0000;">0</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
scene.<span style="color: #660066;">add</span><span style="color: #009900;">&#40;</span>cone<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></div></div>
<h3><span id="toc8">直線</span></h3>
<p>下の例では(0,0,0)から(5,75,100)まで白の線を描きます。</p>
<div class="codecolorer-container javascript dawn" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:400px;"><div class="javascript codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap;"><span style="color: #000066; font-weight: bold;">const</span> lineMaterial <span style="color: #339933;">=</span> <span style="color: #000066; font-weight: bold;">new</span> THREE.<span style="color: #660066;">LineBasicMaterial</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#123;</span> color<span style="color: #339933;">:</span> 0xffffff <span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
<span style="color: #000066; font-weight: bold;">const</span> points <span style="color: #339933;">=</span> <span style="color: #009900;">&#91;</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">;</span><br />
points.<span style="color: #660066;">push</span><span style="color: #009900;">&#40;</span><span style="color: #000066; font-weight: bold;">new</span> THREE.<span style="color: #660066;">Vector3</span><span style="color: #009900;">&#40;</span><span style="color: #CC0000;">0</span><span style="color: #339933;">,</span> <span style="color: #CC0000;">0</span><span style="color: #339933;">,</span> <span style="color: #CC0000;">0</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
points.<span style="color: #660066;">push</span><span style="color: #009900;">&#40;</span><span style="color: #000066; font-weight: bold;">new</span> THREE.<span style="color: #660066;">Vector3</span><span style="color: #009900;">&#40;</span><span style="color: #CC0000;">50</span><span style="color: #339933;">,</span> <span style="color: #CC0000;">75</span><span style="color: #339933;">,</span> <span style="color: #CC0000;">100</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
<span style="color: #000066; font-weight: bold;">const</span> lineGeometry <span style="color: #339933;">=</span> <span style="color: #000066; font-weight: bold;">new</span> THREE.<span style="color: #660066;">BufferGeometry</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">setFromPoints</span><span style="color: #009900;">&#40;</span>points<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
<span style="color: #000066; font-weight: bold;">const</span> line <span style="color: #339933;">=</span> <span style="color: #000066; font-weight: bold;">new</span> THREE.<span style="color: #660066;">Line</span><span style="color: #009900;">&#40;</span>lineGeometry<span style="color: #339933;">,</span> lineMaterial<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
scene.<span style="color: #660066;">add</span><span style="color: #009900;">&#40;</span>line<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></div></div>
]]></content:encoded>
					
					<wfw:commentRss>https://stabucky.com/wp/archives/19300/feed</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
		<item>
		<title>正規表現\wが対応している具体的な内容</title>
		<link>https://stabucky.com/wp/archives/19103</link>
					<comments>https://stabucky.com/wp/archives/19103#respond</comments>
		
		<dc:creator><![CDATA[stabucky]]></dc:creator>
		<pubDate>Thu, 12 Dec 2024 23:49:46 +0000</pubDate>
				<category><![CDATA[JavaScript]]></category>
		<category><![CDATA[正規表現]]></category>
		<guid isPermaLink="false">https://stabucky.com/wp/?p=19103</guid>

					<description><![CDATA[正規表現に\wというのがあります。 word characterの略と思われます。 一般に「英単語に使われる文字」を抽出する際に使われます。 いつも漠然と使っていましたが、具体的にはどの文字に対応しているのでしょうか。  [&#8230;]]]></description>
										<content:encoded><![CDATA[<p>正規表現に\wというのがあります。<br />
word characterの略と思われます。<br />
一般に「英単語に使われる文字」を抽出する際に使われます。<br />
いつも漠然と使っていましたが、具体的にはどの文字に対応しているのでしょうか。</p>
<p>先に答えを書きます。</p>
<p>0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ_abcdefghijklmnopqrstuvwxyz</p>
<p>これはJavaScriptで実際にコードを書いて\wにヒットするものを出力したものです。<br />
半角の数字、英大文字、英小文字、アンダースコアが該当します。<br />
スペース、ドットなどは該当しません。<br />
[0-9A-Za-z_]と書くのと同じです。</p>
<p>蛇足ですがこれを出力する際に使ったコードです。</p>
<div class="codecolorer-container javascript dawn" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:400px;"><div class="javascript codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap;"><span style="color: #006600; font-style: italic;">// 英数字（word characters）を格納する配列</span><br />
<span style="color: #000066; font-weight: bold;">const</span> wordCharacters <span style="color: #339933;">=</span> <span style="color: #009900;">&#91;</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">;</span><br />
<br />
<span style="color: #006600; font-style: italic;">// ASCIIコード32から126までの文字を走査</span><br />
<span style="color: #000066; font-weight: bold;">for</span> <span style="color: #009900;">&#40;</span>let asciiCode <span style="color: #339933;">=</span> <span style="color: #CC0000;">32</span><span style="color: #339933;">;</span> asciiCode <span style="color: #339933;">&lt;</span> <span style="color: #CC0000;">127</span><span style="color: #339933;">;</span> asciiCode<span style="color: #339933;">++</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span><br />
&nbsp; <span style="color: #006600; font-style: italic;">// ASCIIコードを文字に変換</span><br />
&nbsp; <span style="color: #000066; font-weight: bold;">const</span> currentCharacter <span style="color: #339933;">=</span> <span style="">String</span>.<span style="color: #660066;">fromCharCode</span><span style="color: #009900;">&#40;</span>asciiCode<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; <br />
&nbsp; <span style="color: #006600; font-style: italic;">// 英数字（word character）の場合のみ配列に追加</span><br />
&nbsp; <span style="color: #000066; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span>currentCharacter.<span style="color: #660066;">match</span><span style="color: #009900;">&#40;</span><span style="color: #009966; font-style: italic;">/\w/</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; wordCharacters.<span style="color: #660066;">push</span><span style="color: #009900;">&#40;</span>currentCharacter<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; <span style="color: #009900;">&#125;</span><br />
<span style="color: #009900;">&#125;</span><br />
<br />
<span style="color: #006600; font-style: italic;">// 抽出した英数字を文字列として出力</span><br />
console.<span style="color: #660066;">log</span><span style="color: #009900;">&#40;</span>wordCharacters.<span style="color: #660066;">join</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></div></div>
]]></content:encoded>
					
					<wfw:commentRss>https://stabucky.com/wp/archives/19103/feed</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
		<item>
		<title>氏名、メアドなどを自動的にセットするブックマークレット</title>
		<link>https://stabucky.com/wp/archives/19048</link>
					<comments>https://stabucky.com/wp/archives/19048#respond</comments>
		
		<dc:creator><![CDATA[stabucky]]></dc:creator>
		<pubDate>Sun, 01 Dec 2024 09:15:54 +0000</pubDate>
				<category><![CDATA[JavaScript]]></category>
		<category><![CDATA[ブックマークレット]]></category>
		<guid isPermaLink="false">https://stabucky.com/wp/?p=19048</guid>

					<description><![CDATA[最近は自動的にIDやパスワードをセットしてくれる機能がブラウザに備わっています。 しかし、未知のフォームの場合はセットできません。 その場合に使えるブックマークレットを作りました。 主に企業のウェビナー申し込みを想定して [&#8230;]]]></description>
										<content:encoded><![CDATA[<p>最近は自動的にIDやパスワードをセットしてくれる機能がブラウザに備わっています。<br />
しかし、未知のフォームの場合はセットできません。<br />
その場合に使えるブックマークレットを作りました。<br />
主に企業のウェビナー申し込みを想定しています。</p>

  <div id="toc" class="toc tnt-number toc-center tnt-number border-element"><input type="checkbox" class="toc-checkbox" id="toc-checkbox-8" checked><label class="toc-title" for="toc-checkbox-8">目次</label>
    <div class="toc-content">
    <ol class="toc-list open"><li><a href="#toc1" tabindex="0">ブックマークレット</a></li><li><a href="#toc2" tabindex="0">使い方</a></li></ol>
    </div>
  </div>

<h2><span id="toc1">ブックマークレット</span></h2>
<p>下のコードをテキストエディタなどで開き、次の箇所を自分の情報に書き換えます。</p>
<p>last_name : 姓 例&#8221;山田&#8221;<br />
first_name : 名 例&#8221;太郎&#8221;<br />
mail : メールアドレス 例&#8221;yamada@example.com&#8221;<br />
phone : 電話番号 例&#8221;0459991234&#8243;<br />
address : 住所 例&#8221;神奈川県横浜市保土ケ谷区&#8221;<br />
organization : 組織・企業 例&#8221;明訓〇〇会社&#8221;<br />
position : 役職 例&#8221;一般&#8221;</p>
<div class="codecolorer-container text dawn" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:400px;"><div class="text codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap;">javascript:(function(){first_name=&quot;太郎&quot;;last_name=&quot;山田&quot;;mail=&quot;yamada@example.com&quot;;phone=&quot;0459991234&quot;;address=&quot;神奈川県横浜市保土ケ谷区&quot;;organization=&quot;明訓〇〇会社&quot;;position=&quot;一般&quot;;parts=document.querySelectorAll(&quot;input&quot;);parts.forEach(function(part){if(part.id.match(/first/i)){part.value=first_name};if(part.id.match(/last/i)){part.value=last_name};if(part.id.match(/mail/i)){part.value=mail};if(part.id.match(/phone/i)){part.value=phone};if(part.id.match(/address/i)){part.value=address};if(part.id.match(/(org|com)/i)){part.value=organization};if(part.id.match(/title/i)){part.value=position};})})()</div></div>
<h2><span id="toc2">使い方</span></h2>
<p>使い方は次のとおりです。Chromeの場合で説明しますが他のブラウザでもほぼ同じです。</p>
<p>適当なブックマークを作ります。<br />
すべてのブックマークから該当のブックマークを選び右クリックをします。<br />
編集を選択します。<br />
名前に「autoinput」など適当な文字列をセットします。<br />
URLに先ほど編集したコードをコピペします。<br />
保存をクリックします。</p>
<p><img loading="lazy" decoding="async" src="https://stabucky.com/wp/wp-content/uploads/2024/12/bookmarklet.png" alt="" width="502" height="126" class="aligncenter size-full wp-image-19049" srcset="https://stabucky.com/wp/wp-content/uploads/2024/12/bookmarklet.png 502w, https://stabucky.com/wp/wp-content/uploads/2024/12/bookmarklet-500x125.png 500w" sizes="(max-width: 502px) 100vw, 502px" /></p>
<p>もし対応していないウェブサイトがあればコメントで教えて下さい。</p>
]]></content:encoded>
					
					<wfw:commentRss>https://stabucky.com/wp/archives/19048/feed</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
		<item>
		<title>ローカルで別ファイルを読み込む方法</title>
		<link>https://stabucky.com/wp/archives/17284</link>
					<comments>https://stabucky.com/wp/archives/17284#respond</comments>
		
		<dc:creator><![CDATA[stabucky]]></dc:creator>
		<pubDate>Thu, 06 Jun 2024 23:52:30 +0000</pubDate>
				<category><![CDATA[JavaScript]]></category>
		<category><![CDATA[tips]]></category>
		<guid isPermaLink="false">https://stabucky.com/wp/?p=17284</guid>

					<description><![CDATA[JavaScriptを使うとHTMLにテキストなどの外部ファイルを読み込めます。 ただし、これはサーバ環境の話で、ローカル環境ではできません。 目次 状況代替策 状況 本当に無理なのか。調べてみました。 Claudeに訊 [&#8230;]]]></description>
										<content:encoded><![CDATA[<p>JavaScriptを使うとHTMLにテキストなどの外部ファイルを読み込めます。<br />
ただし、これはサーバ環境の話で、ローカル環境ではできません。<span id="more-17284"></span></p>

  <div id="toc" class="toc tnt-number toc-center tnt-number border-element"><input type="checkbox" class="toc-checkbox" id="toc-checkbox-10" checked><label class="toc-title" for="toc-checkbox-10">目次</label>
    <div class="toc-content">
    <ol class="toc-list open"><li><a href="#toc1" tabindex="0">状況</a></li><li><a href="#toc2" tabindex="0">代替策</a></li></ol>
    </div>
  </div>

<h2><span id="toc1">状況</span></h2>
<p>本当に無理なのか。調べてみました。<br />
Claudeに訊いてみます。</p>
<blockquote><p>ローカルファイルシステムでHTMLファイルを直接開いた場合、JavaScriptからファイルを生成して読み込むことはブラウザのセキュリティ制限によって制限されています。<br />
セキュリティ上の理由から、ローカルファイルシステム上でJavaScriptからファイルを生成したり読み込んだりすることは許可されていないためです。<br />
そのため、ローカルファイルを直接開いて別のテキストファイルを読み込む方法は、実際にはほとんどありません。<br />
できる対応は以下の2つになります。<br />
1. ローカルサーバーを立ち上げる<br />
簡易的なHTTPサーバーをローカルで立ち上げ、そのサーバー経由でファイルを読み込む。<br />
この方法ならば、XMLHttpRequestやfetchを使ってファイルを読み込めます。<br />
2. FileReaderAPIを使い、ユーザーにファイルを選択させる<br />
ユーザーが明示的にファイルを選択する必要があります。<br />
セキュリティ制限のためやむを得ませんが、サーバー環境に移行するか、ユーザー入力を受け付けることになります。<br />
完全にプログラムだけで動的にローカルファイルを読み込むことはできないようです。</p></blockquote>
<p>やはりだめなようです。</p>
<h2><span id="toc2">代替策</span></h2>
<p>外部のテキストファイルを読み込むことはできませんが、外部のJSファイルであれば読み込めます。<br />
これで代替します。</p>
<p>sample.html</p>
<div class="codecolorer-container text dawn" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:400px;"><div class="text codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap;">&lt;!DOCTYPE html&gt;<br />
&lt;html&gt;<br />
&lt;head&gt;<br />
&nbsp; &lt;meta charset=&quot;UTF-8&quot;&gt;<br />
&nbsp; &lt;title&gt;Text Display&lt;/title&gt;<br />
&lt;/head&gt;<br />
&lt;body&gt;<br />
&nbsp; &lt;div id=&quot;textContainer&quot;&gt;&lt;/div&gt;<br />
&nbsp; &lt;script src=&quot;textReader.js&quot;&gt;&lt;/script&gt;<br />
&nbsp; &lt;script&gt;<br />
&nbsp; &nbsp; const textContent = getTextContent();<br />
&nbsp; &nbsp; document.querySelector(&quot;#textContainer&quot;).innerText = textContent;<br />
&nbsp; &lt;/script&gt;<br />
&lt;/body&gt;<br />
&lt;/html&gt;</div></div>
<p>textReader.js</p>
<div class="codecolorer-container text dawn" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:400px;"><div class="text codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap;">function getTextContent() {<br />
&nbsp; const text = `<br />
おはようございます。今朝は良い天気です。<br />
&nbsp; `;<br />
&nbsp; const trimmedText = text.trim();<br />
&nbsp; return trimmedText;<br />
}</div></div>
<p>テンプレートリテラルを使うと、バッククォート(`)で囲んだ中で改行を含めることができます。<br />
上のコードの「おはようございます。今朝は良い天気です。」のところにテキストを貼り付ければHTML側に表示されます。<br />
複数行でも問題ありません。</p>
]]></content:encoded>
					
					<wfw:commentRss>https://stabucky.com/wp/archives/17284/feed</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
		<item>
		<title>JavaScriptでGraphvizを使う方法</title>
		<link>https://stabucky.com/wp/archives/16852</link>
					<comments>https://stabucky.com/wp/archives/16852#respond</comments>
		
		<dc:creator><![CDATA[stabucky]]></dc:creator>
		<pubDate>Wed, 01 May 2024 03:22:42 +0000</pubDate>
				<category><![CDATA[JavaScript]]></category>
		<category><![CDATA[DOT]]></category>
		<category><![CDATA[Graphviz]]></category>
		<guid isPermaLink="false">https://stabucky.com/wp/?p=16852</guid>

					<description><![CDATA[JavaScriptでGraphvizを使う方法についてまとめます。 基本 HTMLで書いたときの全体です。 このままコピペして拡張子を.htmlに保存して開くと描画されるはずです。 &#60;!DOCTYPE html&#038; [&#8230;]]]></description>
										<content:encoded><![CDATA[<p>JavaScriptでGraphvizを使う方法についてまとめます。<span id="more-16852"></span></p>
<h3><span id="toc1">基本</span></h3>
<p>HTMLで書いたときの全体です。<br />
このままコピペして拡張子を.htmlに保存して開くと描画されるはずです。</p>
<div class="codecolorer-container text dawn" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:400px;"><div class="text codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap;">&lt;!DOCTYPE html&gt;<br />
&lt;meta charset=&quot;utf-8&quot;&gt;<br />
&lt;body&gt;<br />
&lt;div id=&quot;graph0&quot;&gt;&lt;/div&gt;<br />
&lt;script src=&quot;https://d3js.org/d3.v7.min.js&quot;&gt;&lt;/script&gt;<br />
&lt;script src=&quot;https://unpkg.com/viz.js@1.8.1/viz.js&quot; type=&quot;javascript/worker&quot;&gt;&lt;/script&gt;<br />
&lt;script src=&quot;https://unpkg.com/d3-graphviz@2.6.1/build/d3-graphviz.js&quot;&gt;&lt;/script&gt;<br />
&lt;script&gt;<br />
dotstr = &quot;digraph{a-&gt;b;b-&gt;c;b-&gt;d;}&quot;;<br />
d3.select(&quot;#graph0&quot;).graphviz()<br />
&nbsp; .fade(false)<br />
&nbsp; .renderDot(dotstr);<br />
&lt;/script&gt;<br />
&lt;/body&gt;</div></div>
<p><img loading="lazy" decoding="async" src="https://stabucky.com/wp/wp-content/uploads/2024/05/dot0.png" alt="" width="186" height="255" class="alignnone size-full wp-image-16854" /></p>
<h3><span id="toc2">応用</span></h3>
<p>日本語も使えます。クォートで挟む必要がありません。<br />
なお、JavaScriptの機能として、下の通り「`」で挟むと改行できます。</p>
<div class="codecolorer-container text dawn" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:400px;"><div class="text codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap;">&lt;div id=&quot;graph1&quot;&gt;&lt;/div&gt;<br />
&lt;script&gt;<br />
d3.select(&quot;#graph1&quot;).graphviz()<br />
&nbsp; .fade(false)<br />
&nbsp; .renderDot(`graph{<br />
&nbsp; &nbsp; 新宿--八王子[color=orange];<br />
&nbsp; &nbsp; 新宿--調布--八王子[color=navy];<br />
&nbsp; &nbsp; 調布--多摩センター--橋本[color=navy];<br />
&nbsp; &nbsp; 町田--橋本--八王子[color=green];<br />
&nbsp; &nbsp; 新宿--新百合ヶ丘--町田[color=red];<br />
&nbsp; &nbsp; 新百合ヶ丘--多摩センター[color=red]}`<br />
&nbsp; );<br />
&lt;/script&gt;</div></div>
<p><img loading="lazy" decoding="async" src="https://stabucky.com/wp/wp-content/uploads/2024/05/dot1.png" alt="" width="381" height="447" class="alignnone size-full wp-image-16855" /></p>
]]></content:encoded>
					
					<wfw:commentRss>https://stabucky.com/wp/archives/16852/feed</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
		<item>
		<title>JavaScriptでユニコードをデコードする関数</title>
		<link>https://stabucky.com/wp/archives/16504</link>
					<comments>https://stabucky.com/wp/archives/16504#respond</comments>
		
		<dc:creator><![CDATA[stabucky]]></dc:creator>
		<pubDate>Wed, 21 Feb 2024 12:21:14 +0000</pubDate>
				<category><![CDATA[JavaScript]]></category>
		<category><![CDATA[Text2What]]></category>
		<guid isPermaLink="false">https://stabucky.com/wp/?p=16504</guid>

					<description><![CDATA[ユニコードは「\uXXXX」の形式で表されます。 例えば「都」は「\u90fd」になります。 JSONは文字列をユニコードで表します。 例えばこのようになります。 &#123; &#34;\u90fd\u9053\u5 [&#8230;]]]></description>
										<content:encoded><![CDATA[<p>ユニコードは「\uXXXX」の形式で表されます。<br />
例えば「都」は「\u90fd」になります。<br />
JSONは文字列をユニコードで表します。<span id="more-16504"></span></p>
<p>例えばこのようになります。</p>
<div class="codecolorer-container javascript dawn" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:400px;"><div class="javascript codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap;"><span style="color: #009900;">&#123;</span><br />
<span style="color: #3366CC;">&quot;<span style="color: #000099; font-weight: bold;">\u</span>90fd<span style="color: #000099; font-weight: bold;">\u</span>9053<span style="color: #000099; font-weight: bold;">\u</span>5e9c<span style="color: #000099; font-weight: bold;">\u</span>770c&quot;</span><span style="color: #339933;">:</span><span style="color: #3366CC;">&quot;<span style="color: #000099; font-weight: bold;">\u</span>5317<span style="color: #000099; font-weight: bold;">\u</span>6d77<span style="color: #000099; font-weight: bold;">\u</span>9053&quot;</span><span style="color: #339933;">,</span><br />
<span style="color: #3366CC;">&quot;<span style="color: #000099; font-weight: bold;">\u</span>59d3&quot;</span><span style="color: #339933;">:</span><span style="color: #3366CC;">&quot;<span style="color: #000099; font-weight: bold;">\u</span>77f3<span style="color: #000099; font-weight: bold;">\u</span>5ddd&quot;</span><span style="color: #339933;">,</span><br />
<span style="color: #3366CC;">&quot;<span style="color: #000099; font-weight: bold;">\u</span>540d&quot;</span><span style="color: #339933;">:</span><span style="color: #3366CC;">&quot;<span style="color: #000099; font-weight: bold;">\u</span>7ae0&quot;</span><span style="color: #339933;">,</span><br />
<span style="color: #3366CC;">&quot;<span style="color: #000099; font-weight: bold;">\u</span>6027<span style="color: #000099; font-weight: bold;">\u</span>5225&quot;</span><span style="color: #339933;">:</span><span style="color: #3366CC;">&quot;<span style="color: #000099; font-weight: bold;">\u</span>7537&quot;</span><br />
<span style="color: #009900;">&#125;</span></div></div>
<p>このユニコードを通常の文字に変換（デコード）するJavaScriptの関数を考えました。</p>
<div class="codecolorer-container javascript dawn" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:400px;"><div class="javascript codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap;"><span style="color: #000066; font-weight: bold;">function</span> decode_unicode<span style="color: #009900;">&#40;</span>src<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span><br />
&nbsp; <span style="color: #006600; font-style: italic;">// 変数宣言</span><br />
&nbsp; <span style="color: #000066; font-weight: bold;">const</span> regex <span style="color: #339933;">=</span> <span style="color: #009966; font-style: italic;">/\\u.{4}/ig</span><span style="color: #339933;">;</span><br />
&nbsp; <span style="color: #000066; font-weight: bold;">const</span> replacementFunction <span style="color: #339933;">=</span> <span style="color: #009900;">&#40;</span>all<span style="color: #009900;">&#41;</span> <span style="color: #339933;">=&gt;</span> <span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; <span style="color: #006600; font-style: italic;">// Unicodeエスケープシーケンスを16進数に変換</span><br />
&nbsp; &nbsp; <span style="color: #000066; font-weight: bold;">const</span> hexCode <span style="color: #339933;">=</span> all.<span style="color: #660066;">replace</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;<span style="color: #000099; font-weight: bold;">\\</span>u&quot;</span><span style="color: #339933;">,</span> <span style="color: #3366CC;">&quot;0x&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; <span style="color: #006600; font-style: italic;">// 16進数コードから文字を取得</span><br />
&nbsp; &nbsp; <span style="color: #000066; font-weight: bold;">return</span> <span style="">String</span>.<span style="color: #660066;">fromCharCode</span><span style="color: #009900;">&#40;</span>parseInt<span style="color: #009900;">&#40;</span>hexCode<span style="color: #339933;">,</span> <span style="color: #CC0000;">16</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; <span style="color: #009900;">&#125;</span><span style="color: #339933;">;</span><br />
&nbsp; <span style="color: #006600; font-style: italic;">// 正規表現でマッチした部分文字列を置換</span><br />
&nbsp; <span style="color: #000066; font-weight: bold;">const</span> result <span style="color: #339933;">=</span> src.<span style="color: #660066;">replace</span><span style="color: #009900;">&#40;</span>regex<span style="color: #339933;">,</span> replacementFunction<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; <span style="color: #006600; font-style: italic;">// 結果を返す</span><br />
&nbsp; <span style="color: #000066; font-weight: bold;">return</span> result<span style="color: #339933;">;</span><br />
<span style="color: #009900;">&#125;</span></div></div>
<p>これを使うと先程の文字列が次のようになります。</p>
<div class="codecolorer-container javascript dawn" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:400px;"><div class="javascript codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap;"><span style="color: #009900;">&#123;</span><br />
<span style="color: #3366CC;">&quot;都道府県&quot;</span><span style="color: #339933;">:</span><span style="color: #3366CC;">&quot;北海道&quot;</span><span style="color: #339933;">,</span><br />
<span style="color: #3366CC;">&quot;姓&quot;</span><span style="color: #339933;">:</span><span style="color: #3366CC;">&quot;石川&quot;</span><span style="color: #339933;">,</span><br />
<span style="color: #3366CC;">&quot;名&quot;</span><span style="color: #339933;">:</span><span style="color: #3366CC;">&quot;章&quot;</span><span style="color: #339933;">,</span><br />
<span style="color: #3366CC;">&quot;性別&quot;</span><span style="color: #339933;">:</span><span style="color: #3366CC;">&quot;男&quot;</span><br />
<span style="color: #009900;">&#125;</span></div></div>
<p>次のページで試すことができます。</p>
<div class="linkcard"><div class="lkc-external-wrap"><a rel="noopener" class="lkc-link no_icon" href="https://tool.stabucky.com/convert/text2what.htm" data-lkc-id="121" target="_blank"><div class="lkc-card"><div class="lkc-info"><div class="lkc-favicon"><img loading="lazy" decoding="async" src="https://www.google.com/s2/favicons?domain=tool.stabucky.com" alt="" width="16" height="16" /></div><div class="lkc-domain">tool.stabucky.com</div><div class="lkc-share"> <div class="lkc-sns-hb">3 Users</div> <div class="lkc-sns-po">4 Pockets</div></div></div><div class="lkc-content"><figure class="lkc-thumbnail"><img decoding="async" class="lkc-thumbnail-img" src="https://s.wordpress.com/mshots/v1/https%3A%2F%2Ftool.stabucky.com%2Fconvert%2Ftext2what.htm?w=200" width="100px" height="108px" alt="" /></figure><div class="lkc-title">Text2What</div><div class="lkc-url" title="https://tool.stabucky.com/convert/text2what.htm">https://tool.stabucky.com/convert/text2what.htm</div></div><div class="clear"></div></div></a></div></div>
]]></content:encoded>
					
					<wfw:commentRss>https://stabucky.com/wp/archives/16504/feed</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
		<item>
		<title>jQueryを使わずにHTML上の値を操作する方法 &#8211; 脱jQuery</title>
		<link>https://stabucky.com/wp/archives/16439</link>
					<comments>https://stabucky.com/wp/archives/16439#respond</comments>
		
		<dc:creator><![CDATA[stabucky]]></dc:creator>
		<pubDate>Sat, 03 Feb 2024 01:30:51 +0000</pubDate>
				<category><![CDATA[JavaScript]]></category>
		<category><![CDATA[querySelector]]></category>
		<guid isPermaLink="false">https://stabucky.com/wp/?p=16439</guid>

					<description><![CDATA[私がJavaScriptを学んだときは、HTML上の値を取得するときはgetElementByIdなどを使っていました。 その後、jQueryが登場し、CSSと同じセレクタが扱えるようになりました。 そして今は、jQue [&#8230;]]]></description>
										<content:encoded><![CDATA[<p>私がJavaScriptを学んだときは、HTML上の値を取得するときはgetElementByIdなどを使っていました。<br />
その後、jQueryが登場し、CSSと同じセレクタが扱えるようになりました。<br />
そして今は、jQueryを使わずにセレクタが扱えます。<br />
今回はJavaScriptでjQueryを使わずにHTML上の値を取得、設定する方法をまとめます。<span id="more-16439"></span></p>

  <div id="toc" class="toc tnt-number toc-center tnt-number border-element"><input type="checkbox" class="toc-checkbox" id="toc-checkbox-16" checked><label class="toc-title" for="toc-checkbox-16">目次</label>
    <div class="toc-content">
    <ol class="toc-list open"><li><a href="#toc1" tabindex="0">querySelectorで一つ取得</a></li><li><a href="#toc2" tabindex="0">querySelectorAllで全て取得</a></li><li><a href="#toc3" tabindex="0">ラジオとチェックボックスで取得</a><ol><li><a href="#toc4" tabindex="0">ラジオ</a></li><li><a href="#toc5" tabindex="0">チェックボックス</a></li></ol></li><li><a href="#toc6" tabindex="0">値の取得（ゲット）</a></li><li><a href="#toc7" tabindex="0">値の設定（セット）</a></li><li><a href="#toc8" tabindex="0">フォームのサンプル</a></li></ol>
    </div>
  </div>

<h2><span id="toc1">querySelectorで一つ取得</span></h2>
<p>jQueryの便利な点の一つはオブジェクトを指定する際にCSSのセレクタが使えたことですが、querySelectorを使うと同様にCSSのセレクタが使えます。<br />
idであれば#idとするとオブジェクトを特定できます。</p>
<div class="codecolorer-container html4strict dawn" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:400px;"><div class="html4strict codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap;"><span style="color: #009900;">&lt;<a href="http://december.com/html/4/element/input.html"><span style="color: #000000; font-weight: bold;">input</span></a> <span style="color: #000066;">type</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;text&quot;</span> <span style="color: #000066;">id</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;nezumi&quot;</span> <span style="color: #000066;">value</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;ねずみ&quot;</span>&gt;</span><br />
<span style="color: #009900;">&lt;<a href="http://december.com/html/4/element/textarea.html"><span style="color: #000000; font-weight: bold;">textarea</span></a> <span style="color: #000066;">id</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;ushi&quot;</span>&gt;</span>うし<span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><a href="http://december.com/html/4/element/textarea.html"><span style="color: #000000; font-weight: bold;">textarea</span></a>&gt;</span><br />
<span style="color: #009900;">&lt;<a href="http://december.com/html/4/element/div.html"><span style="color: #000000; font-weight: bold;">div</span></a> <span style="color: #000066;">id</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;tora&quot;</span>&gt;</span>とら<span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><a href="http://december.com/html/4/element/div.html"><span style="color: #000000; font-weight: bold;">div</span></a>&gt;</span></div></div>
<div class="codecolorer-container javascript dawn" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:400px;"><div class="javascript codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap;">part<span style="color: #339933;">=</span>document.<span style="color: #660066;">querySelector</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;#nezumi&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
console.<span style="color: #660066;">log</span><span style="color: #009900;">&#40;</span>part.<span style="color: #660066;">value</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
<br />
part<span style="color: #339933;">=</span>document.<span style="color: #660066;">querySelector</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;#ushi&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
console.<span style="color: #660066;">log</span><span style="color: #009900;">&#40;</span>part.<span style="color: #660066;">value</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
<br />
part<span style="color: #339933;">=</span>document.<span style="color: #660066;">querySelector</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;#tora&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
console.<span style="color: #660066;">log</span><span style="color: #009900;">&#40;</span>part.<span style="color: #660066;">innerText</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></div></div>
<h2><span id="toc2">querySelectorAllで全て取得</span></h2>
<p>#idであれば対象は一つだけですが tagや.classだと複数になります。<br />
querySelectorだと先頭の一つが取得できます。<br />
querySelectorAllにすると対象全てが取得できます。<br />
複数取得した場合はforEachで対象を一つずつ処理できます。</p>
<div class="codecolorer-container javascript dawn" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:400px;"><div class="javascript codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap;"><span style="color: #006600; font-style: italic;">//querySelectorだと、対象が複数ある場合、先頭のみ取得。</span><br />
part<span style="color: #339933;">=</span>document.<span style="color: #660066;">querySelector</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;div&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
console.<span style="color: #660066;">log</span><span style="color: #009900;">&#40;</span>part.<span style="color: #660066;">innerText</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
<br />
<span style="color: #006600; font-style: italic;">//querySelectorAllだと、全て取得される。</span><br />
parts<span style="color: #339933;">=</span>document.<span style="color: #660066;">querySelectorAll</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;div&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
parts.<span style="color: #660066;">forEach</span><span style="color: #009900;">&#40;</span><span style="color: #000066; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span>part<span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span><br />
&nbsp; console.<span style="color: #660066;">log</span><span style="color: #009900;">&#40;</span>part.<span style="color: #660066;">innerText</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
<span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></div></div>
<h2><span id="toc3">ラジオとチェックボックスで取得</span></h2>
<p>radioとcheckboxはチェックがついているものを取得します。<br />
多くの場合、name属性があるので[name=name]:checkedを使うとよいです。</p>
<h3><span id="toc4">ラジオ</span></h3>
<div class="codecolorer-container html4strict dawn" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:400px;"><div class="html4strict codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap;"><span style="color: #009900;">&lt;<a href="http://december.com/html/4/element/input.html"><span style="color: #000000; font-weight: bold;">input</span></a> <span style="color: #000066;">type</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;radio&quot;</span> <span style="color: #000066;">name</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;seiza&quot;</span> <span style="color: #000066;">value</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;おうし&quot;</span>&gt;</span>おうし<br />
<span style="color: #009900;">&lt;<a href="http://december.com/html/4/element/input.html"><span style="color: #000000; font-weight: bold;">input</span></a> <span style="color: #000066;">type</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;radio&quot;</span> <span style="color: #000066;">name</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;seiza&quot;</span> <span style="color: #000066;">value</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;さそり&quot;</span> checked&gt;</span>さそり</div></div>
<div class="codecolorer-container javascript dawn" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:400px;"><div class="javascript codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap;">part<span style="color: #339933;">=</span>document.<span style="color: #660066;">querySelector</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;[name=seiza]:checked&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
console.<span style="color: #660066;">log</span><span style="color: #009900;">&#40;</span>part.<span style="color: #660066;">value</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></div></div>
<h3><span id="toc5">チェックボックス</span></h3>
<div class="codecolorer-container html4strict dawn" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:400px;"><div class="html4strict codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap;"><span style="color: #009900;">&lt;<a href="http://december.com/html/4/element/input.html"><span style="color: #000000; font-weight: bold;">input</span></a> <span style="color: #000066;">type</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;checkbox&quot;</span> <span style="color: #000066;">name</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;hoi&quot;</span> <span style="color: #000066;">value</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;ひがし&quot;</span>&gt;</span>ひがし<br />
<span style="color: #009900;">&lt;<a href="http://december.com/html/4/element/input.html"><span style="color: #000000; font-weight: bold;">input</span></a> <span style="color: #000066;">type</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;checkbox&quot;</span> <span style="color: #000066;">name</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;hoi&quot;</span> <span style="color: #000066;">value</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;にし&quot;</span> checked&gt;</span>にし<br />
<span style="color: #009900;">&lt;<a href="http://december.com/html/4/element/input.html"><span style="color: #000000; font-weight: bold;">input</span></a> <span style="color: #000066;">type</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;checkbox&quot;</span> <span style="color: #000066;">name</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;hoi&quot;</span> <span style="color: #000066;">value</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;みなみ&quot;</span>&gt;</span>みなみ<br />
<span style="color: #009900;">&lt;<a href="http://december.com/html/4/element/input.html"><span style="color: #000000; font-weight: bold;">input</span></a> <span style="color: #000066;">type</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;checkbox&quot;</span> <span style="color: #000066;">name</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;hoi&quot;</span> <span style="color: #000066;">value</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;きた&quot;</span> checked&gt;</span>きた</div></div>
<div class="codecolorer-container javascript dawn" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:400px;"><div class="javascript codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap;">parts<span style="color: #339933;">=</span>document.<span style="color: #660066;">querySelectorAll</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;[name=hoi]:checked&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
parts.<span style="color: #660066;">forEach</span><span style="color: #009900;">&#40;</span><span style="color: #000066; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span>part<span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span><br />
&nbsp; console.<span style="color: #660066;">log</span><span style="color: #009900;">&#40;</span>part.<span style="color: #660066;">value</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
<span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span></div></div>
<h2><span id="toc6">値の取得（ゲット）</span></h2>
<p>値の取得方法はタグによって異なります。<br />
HTMLが使える箇所はinnerText、それ以外はvalueでよさそうです。</p>
<p>input : value<br />
textarea : value<br />
div : innerText</p>
<h2><span id="toc7">値の設定（セット）</span></h2>
<p>値のセットは値の取得と同じです。<br />
テキストでなくHTMLをセットする場合はinnerHTMLとします（HTMLはすべて大文字）。</p>
<div class="codecolorer-container html4strict dawn" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:400px;"><div class="html4strict codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap;"><span style="color: #009900;">&lt;<a href="http://december.com/html/4/element/div.html"><span style="color: #000000; font-weight: bold;">div</span></a> <span style="color: #000066;">id</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;one&quot;</span>&gt;&lt;<span style="color: #66cc66;">/</span><a href="http://december.com/html/4/element/div.html"><span style="color: #000000; font-weight: bold;">div</span></a>&gt;</span><br />
<span style="color: #009900;">&lt;<a href="http://december.com/html/4/element/div.html"><span style="color: #000000; font-weight: bold;">div</span></a> <span style="color: #000066;">id</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;two&quot;</span>&gt;&lt;<span style="color: #66cc66;">/</span><a href="http://december.com/html/4/element/div.html"><span style="color: #000000; font-weight: bold;">div</span></a>&gt;</span><br />
<span style="color: #009900;">&lt;<a href="http://december.com/html/4/element/input.html"><span style="color: #000000; font-weight: bold;">input</span></a> <span style="color: #000066;">type</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;text&quot;</span> <span style="color: #000066;">id</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;three&quot;</span> <span style="color: #000066;">value</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;さんばんめ&quot;</span>&gt;</span><br />
<span style="color: #009900;">&lt;<a href="http://december.com/html/4/element/textarea.html"><span style="color: #000000; font-weight: bold;">textarea</span></a> <span style="color: #000066;">id</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;four&quot;</span> <span style="color: #000066;">value</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;よんばんめ&quot;</span>&gt;&lt;<span style="color: #66cc66;">/</span><a href="http://december.com/html/4/element/textarea.html"><span style="color: #000000; font-weight: bold;">textarea</span></a>&gt;</span></div></div>
<div class="codecolorer-container javascript dawn" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:400px;"><div class="javascript codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap;">document.<span style="color: #660066;">querySelector</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;#one&quot;</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">innerText</span><span style="color: #339933;">=</span><span style="color: #3366CC;">&quot;いちばんめ&quot;</span><span style="color: #339933;">;</span><br />
document.<span style="color: #660066;">querySelector</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;#two&quot;</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">innerHTML</span><span style="color: #339933;">=</span><span style="color: #3366CC;">&quot;&lt;a href=''&gt;にばんめ&lt;/a&gt;&quot;</span><span style="color: #339933;">;</span><br />
document.<span style="color: #660066;">querySelector</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;#three&quot;</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">value</span><span style="color: #339933;">=</span><span style="color: #3366CC;">&quot;さんばんめ&quot;</span><span style="color: #339933;">;</span><br />
document.<span style="color: #660066;">querySelector</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;#four&quot;</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">value</span><span style="color: #339933;">=</span><span style="color: #3366CC;">&quot;よばんめ&quot;</span><span style="color: #339933;">;</span></div></div>
<h2><span id="toc8">フォームのサンプル</span></h2>
<div class="codecolorer-container html4strict dawn" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:400px;"><div class="html4strict codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap;"><span style="color: #009900;">&lt;<a href="http://december.com/html/4/element/input.html"><span style="color: #000000; font-weight: bold;">input</span></a> <span style="color: #000066;">type</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;text&quot;</span> <span style="color: #000066;">id</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;txt_src&quot;</span> <span style="color: #000066;">value</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;abcdefgh&quot;</span>&gt;</span><br />
<span style="color: #009900;">&lt;<a href="http://december.com/html/4/element/button.html"><span style="color: #000000; font-weight: bold;">button</span></a> <span style="color: #000066;">type</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;button&quot;</span> <span style="color: #000066;">id</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;btn_doit&quot;</span>&gt;</span>実行<span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><a href="http://december.com/html/4/element/button.html"><span style="color: #000000; font-weight: bold;">button</span></a>&gt;</span><br />
<span style="color: #009900;">&lt;<a href="http://december.com/html/4/element/input.html"><span style="color: #000000; font-weight: bold;">input</span></a> <span style="color: #000066;">type</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;text&quot;</span> <span style="color: #000066;">id</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;txt_dst&quot;</span>&gt;</span><br />
<span style="color: #009900;">&lt;<a href="http://december.com/html/4/element/textarea.html"><span style="color: #000000; font-weight: bold;">textarea</span></a> <span style="color: #000066;">id</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;ta_dst&quot;</span>&gt;&lt;<span style="color: #66cc66;">/</span><a href="http://december.com/html/4/element/textarea.html"><span style="color: #000000; font-weight: bold;">textarea</span></a>&gt;</span><br />
<span style="color: #009900;">&lt;<a href="http://december.com/html/4/element/div.html"><span style="color: #000000; font-weight: bold;">div</span></a> <span style="color: #000066;">id</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;div_dst&quot;</span>&gt;&lt;<span style="color: #66cc66;">/</span><a href="http://december.com/html/4/element/div.html"><span style="color: #000000; font-weight: bold;">div</span></a>&gt;</span></div></div>
<div class="codecolorer-container javascript dawn" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:400px;"><div class="javascript codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap;">document.<span style="color: #660066;">querySelector</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;#btn_doit&quot;</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">onclick</span> <span style="color: #339933;">=</span> <span style="color: #000066; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span><br />
&nbsp; text <span style="color: #339933;">=</span> document.<span style="color: #660066;">querySelector</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;#txt_src&quot;</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">value</span><span style="color: #339933;">;</span><br />
&nbsp; document.<span style="color: #660066;">querySelector</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;#txt_dst&quot;</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">value</span> <span style="color: #339933;">=</span> text<span style="color: #339933;">;</span><br />
&nbsp; document.<span style="color: #660066;">querySelector</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;#ta_dst&quot;</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">value</span> <span style="color: #339933;">=</span> text<span style="color: #339933;">;</span><br />
&nbsp; document.<span style="color: #660066;">querySelector</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;#div_dst&quot;</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">innerText</span> <span style="color: #339933;">=</span> text<span style="color: #339933;">;</span><br />
<span style="color: #009900;">&#125;</span></div></div>
<p><img loading="lazy" decoding="async" src="https://stabucky.com/wp/wp-content/uploads/2024/02/form_sample.png" alt="" width="262" height="185" class="alignnone size-full wp-image-17254" /></p>
]]></content:encoded>
					
					<wfw:commentRss>https://stabucky.com/wp/archives/16439/feed</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
		<item>
		<title>「漸化式を解くツール」</title>
		<link>https://stabucky.com/wp/archives/16060</link>
					<comments>https://stabucky.com/wp/archives/16060#respond</comments>
		
		<dc:creator><![CDATA[stabucky]]></dc:creator>
		<pubDate>Tue, 05 Sep 2023 12:53:00 +0000</pubDate>
				<category><![CDATA[JavaScript]]></category>
		<category><![CDATA[math.js]]></category>
		<category><![CDATA[数学]]></category>
		<category><![CDATA[漸化式]]></category>
		<guid isPermaLink="false">https://stabucky.com/wp/?p=16060</guid>

					<description><![CDATA[漸化式と連立方程式という記事を書きました。 このような形式の漸化式を求めるツールを作りました。 &#28472;&#21270;&#24335;&#12434;&#35299;&#12367;&#12484;&#1254 [&#8230;]]]></description>
										<content:encoded><![CDATA[<p><a href="https://stabucky.com/wp/archives/1924">漸化式と連立方程式</a>という記事を書きました。<br />
このような形式の漸化式を求めるツールを作りました。<span id="more-16060"></span></p>

<a rel="noopener" href="https://tool.stabucky.com/calc/recurrence.htm" title="&#28472;&#21270;&#24335;&#12434;&#35299;&#12367;&#12484;&#12540;&#12523;" class="blogcard-wrap external-blogcard-wrap a-wrap cf" target="_blank"><div class="blogcard external-blogcard eb-left cf"><div class="blogcard-label external-blogcard-label"><span class="fa"></span></div><figure class="blogcard-thumbnail external-blogcard-thumbnail"><img loading="lazy" decoding="async" src="https://s.wordpress.com/mshots/v1/https%3A%2F%2Ftool.stabucky.com%2Fcalc%2Frecurrence.htm?w=160&#038;h=90" alt="" class="blogcard-thumb-image external-blogcard-thumb-image" width="160" height="90" /></figure><div class="blogcard-content external-blogcard-content"><div class="blogcard-title external-blogcard-title">&#28472;&#21270;&#24335;&#12434;&#35299;&#12367;&#12484;&#12540;&#12523;</div><div class="blogcard-snippet external-blogcard-snippet"></div></div><div class="blogcard-footer external-blogcard-footer cf"><div class="blogcard-site external-blogcard-site"><div class="blogcard-favicon external-blogcard-favicon"><img loading="lazy" decoding="async" src="https://www.google.com/s2/favicons?domain=https://tool.stabucky.com/calc/recurrence.htm" alt="" class="blogcard-favicon-image external-blogcard-favicon-image" width="16" height="16" /></div><div class="blogcard-domain external-blogcard-domain">tool.stabucky.com</div></div></div></div></a>
<p><a href="https://stabucky.com/wp/archives/16052">JavaScriptで連立方程式を解く方法</a>に書いた手法を使っています。</p>
]]></content:encoded>
					
					<wfw:commentRss>https://stabucky.com/wp/archives/16060/feed</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
		<item>
		<title>JavaScriptで連立方程式を解く方法</title>
		<link>https://stabucky.com/wp/archives/16052</link>
					<comments>https://stabucky.com/wp/archives/16052#comments</comments>
		
		<dc:creator><![CDATA[stabucky]]></dc:creator>
		<pubDate>Sat, 02 Sep 2023 01:13:50 +0000</pubDate>
				<category><![CDATA[JavaScript]]></category>
		<category><![CDATA[math.js]]></category>
		<category><![CDATA[連立方程式]]></category>
		<guid isPermaLink="false">https://stabucky.com/wp/?p=16052</guid>

					<description><![CDATA[Pythonだといくつか連立方程式を解く方法（ライブラリ）があるのですが、JavaScriptにあるかどうか知りませんでした。 調べるとmath.jsというライブラリがあります。 数学に関する色々なことができます。 行列 [&#8230;]]]></description>
										<content:encoded><![CDATA[<p>Pythonだといくつか連立方程式を解く方法（ライブラリ）があるのですが、JavaScriptにあるかどうか知りませんでした。<br />
調べるとmath.jsというライブラリがあります。<br />
数学に関する色々なことができます。<br />
行列を扱うこともでき、これを使って連立方程式を解くことができます。<span id="more-16052"></span></p>

  <div id="toc" class="toc tnt-number toc-center tnt-number border-element"><input type="checkbox" class="toc-checkbox" id="toc-checkbox-20" checked><label class="toc-title" for="toc-checkbox-20">目次</label>
    <div class="toc-content">
    <ol class="toc-list open"><li><a href="#toc1" tabindex="0">使い方</a></li><li><a href="#toc2" tabindex="0">行列の積</a></li><li><a href="#toc3" tabindex="0">逆行列</a></li><li><a href="#toc4" tabindex="0">連立方程式</a></li></ol>
    </div>
  </div>

<h2><span id="toc1">使い方</span></h2>
<div class="linkcard"><div class="lkc-external-wrap"><a rel="noopener" class="lkc-link no_icon" href="https://mathjs.org" data-lkc-id="95" target="_blank"><div class="lkc-card"><div class="lkc-info"><div class="lkc-favicon"><img loading="lazy" decoding="async" src="https://www.google.com/s2/favicons?domain=mathjs.org" alt="" width="16" height="16" /></div><div class="lkc-domain">mathjs.org</div><div class="lkc-share"> <div class="lkc-sns-hb">46 Users</div> <div class="lkc-sns-po">626 Pockets</div></div></div><div class="lkc-content"><figure class="lkc-thumbnail"><img decoding="async" class="lkc-thumbnail-img" src="https://s.wordpress.com/mshots/v1/https%3A%2F%2Fmathjs.org?w=200" width="100px" height="108px" alt="" /></figure><div class="lkc-title">math.js | an extensive math library for JavaScript and Node.js</div><div class="lkc-url" title="https://mathjs.org">https://mathjs.org</div><div class="lkc-excerpt">Math.js is an extensive math library for JavaScript and Node.js. It features big numbers, complex numbers, matrices, units, and a flexible expression parser.</div></div><div class="clear"></div></div></a></div></div>
<p>CDNが簡単です。</p>
<div class="codecolorer-container text dawn" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:400px;"><div class="text codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap;">&lt;script src=&quot;https://cdnjs.cloudflare.com/ajax/libs/mathjs/11.10.1/math.min.js&quot;&gt;&lt;/script&gt;</div></div>
<h2><span id="toc2">行列の積</span></h2>
<p>まず行列の計算について見てみます。<br />
積は次のとおりです。</p>
<div class="codecolorer-container javascript dawn" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:400px;"><div class="javascript codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap;">x <span style="color: #339933;">=</span> <span style="color: #009900;">&#91;</span><span style="color: #009900;">&#91;</span><span style="color: #CC0000;">1</span><span style="color: #339933;">,</span> <span style="color: #CC0000;">2</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">,</span> <span style="color: #009900;">&#91;</span><span style="color: #CC0000;">3</span><span style="color: #339933;">,</span> <span style="color: #CC0000;">4</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">;</span><br />
y <span style="color: #339933;">=</span> <span style="color: #009900;">&#91;</span><span style="color: #009900;">&#91;</span><span style="color: #CC0000;">2</span><span style="color: #339933;">,</span> <span style="color: #CC0000;">3</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">,</span> <span style="color: #009900;">&#91;</span><span style="color: #CC0000;">4</span><span style="color: #339933;">,</span> <span style="color: #CC0000;">5</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">;</span><br />
<br />
result <span style="color: #339933;">=</span> math.<span style="color: #660066;">multiply</span><span style="color: #009900;">&#40;</span>x<span style="color: #339933;">,</span> y<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
console.<span style="color: #660066;">log</span><span style="color: #009900;">&#40;</span>result<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></div></div>
<p>実行結果<br />
[[10, 13], [22, 29]]</p>
<h2><span id="toc3">逆行列</span></h2>
<div class="codecolorer-container javascript dawn" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:400px;"><div class="javascript codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap;">x <span style="color: #339933;">=</span> <span style="color: #009900;">&#91;</span><span style="color: #009900;">&#91;</span><span style="color: #CC0000;">1</span><span style="color: #339933;">,</span> <span style="color: #CC0000;">2</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">,</span> <span style="color: #009900;">&#91;</span><span style="color: #CC0000;">3</span><span style="color: #339933;">,</span> <span style="color: #CC0000;">4</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">;</span><br />
y <span style="color: #339933;">=</span> <span style="color: #009900;">&#91;</span><span style="color: #009900;">&#91;</span><span style="color: #CC0000;">2</span><span style="color: #339933;">,</span> <span style="color: #CC0000;">3</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">,</span> <span style="color: #009900;">&#91;</span><span style="color: #CC0000;">4</span><span style="color: #339933;">,</span> <span style="color: #CC0000;">5</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">;</span><br />
<br />
result <span style="color: #339933;">=</span> math.<span style="color: #660066;">inv</span><span style="color: #009900;">&#40;</span>x<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
console.<span style="color: #660066;">log</span><span style="color: #009900;">&#40;</span>result<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></div></div>
<p>実行結果<br />
[[-2, 1], [1.5, -0.5]]</p>
<h2><span id="toc4">連立方程式</span></h2>
<p>8元連立方程式を解いてみます。</p>
<p>4x<sub>1</sub>+2x<sub>2</sub>+3x<sub>3</sub>+3x<sub>4</sub>+2x<sub>5</sub>+3x<sub>6</sub>+4x<sub>7</sub>+2x<sub>8</sub>=26<br />
2x<sub>1</sub>+3x<sub>2</sub>+2x<sub>3</sub>+2x<sub>4</sub>+4x<sub>5</sub>+2x<sub>6</sub>+4x<sub>7</sub>+2x<sub>8</sub>=13<br />
3x<sub>1</sub>+4x<sub>2</sub>+4x<sub>3</sub>+4x<sub>4</sub>+2x<sub>5</sub>+3x<sub>6</sub>+2x<sub>7</sub>+3x<sub>8</sub>=0<br />
4x<sub>1</sub>+2x<sub>2</sub>+3x<sub>3</sub>+4x<sub>4</sub>+4x<sub>5</sub>+4x<sub>6</sub>+2x<sub>7</sub>+4x<sub>8</sub>=20<br />
2x<sub>1</sub>+3x<sub>2</sub>+2x<sub>3</sub>+2x<sub>4</sub>+3x<sub>5</sub>+2x<sub>6</sub>+3x<sub>7</sub>+4x<sub>8</sub>=5<br />
3x<sub>1</sub>+4x<sub>2</sub>+4x<sub>3</sub>+3x<sub>4</sub>+2x<sub>5</sub>+4x<sub>6</sub>+3x<sub>7</sub>+2x<sub>8</sub>=5<br />
4x<sub>1</sub>+2x<sub>2</sub>+3x<sub>3</sub>+3x<sub>4</sub>+2x<sub>5</sub>+4x<sub>6</sub>+2x<sub>7</sub>+4x<sub>8</sub>=17<br />
2x<sub>1</sub>+3x<sub>2</sub>+2x<sub>3</sub>+2x<sub>4</sub>+1x<sub>5</sub>+3x<sub>6</sub>+2x<sub>7</sub>+2x<sub>8</sub>=-6</p>
<div class="codecolorer-container javascript dawn" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:400px;"><div class="javascript codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap;">A <span style="color: #339933;">=</span> <span style="color: #009900;">&#91;</span><br />
&nbsp; <span style="color: #009900;">&#91;</span><span style="color: #CC0000;">4</span><span style="color: #339933;">,</span> <span style="color: #CC0000;">2</span><span style="color: #339933;">,</span> <span style="color: #CC0000;">3</span><span style="color: #339933;">,</span> <span style="color: #CC0000;">3</span><span style="color: #339933;">,</span> <span style="color: #CC0000;">2</span><span style="color: #339933;">,</span> <span style="color: #CC0000;">3</span><span style="color: #339933;">,</span> <span style="color: #CC0000;">4</span><span style="color: #339933;">,</span> <span style="color: #CC0000;">2</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">,</span><br />
&nbsp; <span style="color: #009900;">&#91;</span><span style="color: #CC0000;">2</span><span style="color: #339933;">,</span> <span style="color: #CC0000;">3</span><span style="color: #339933;">,</span> <span style="color: #CC0000;">2</span><span style="color: #339933;">,</span> <span style="color: #CC0000;">2</span><span style="color: #339933;">,</span> <span style="color: #CC0000;">4</span><span style="color: #339933;">,</span> <span style="color: #CC0000;">2</span><span style="color: #339933;">,</span> <span style="color: #CC0000;">4</span><span style="color: #339933;">,</span> <span style="color: #CC0000;">2</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">,</span><br />
&nbsp; <span style="color: #009900;">&#91;</span><span style="color: #CC0000;">3</span><span style="color: #339933;">,</span> <span style="color: #CC0000;">4</span><span style="color: #339933;">,</span> <span style="color: #CC0000;">4</span><span style="color: #339933;">,</span> <span style="color: #CC0000;">4</span><span style="color: #339933;">,</span> <span style="color: #CC0000;">2</span><span style="color: #339933;">,</span> <span style="color: #CC0000;">3</span><span style="color: #339933;">,</span> <span style="color: #CC0000;">2</span><span style="color: #339933;">,</span> <span style="color: #CC0000;">3</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">,</span><br />
&nbsp; <span style="color: #009900;">&#91;</span><span style="color: #CC0000;">4</span><span style="color: #339933;">,</span> <span style="color: #CC0000;">2</span><span style="color: #339933;">,</span> <span style="color: #CC0000;">3</span><span style="color: #339933;">,</span> <span style="color: #CC0000;">4</span><span style="color: #339933;">,</span> <span style="color: #CC0000;">4</span><span style="color: #339933;">,</span> <span style="color: #CC0000;">4</span><span style="color: #339933;">,</span> <span style="color: #CC0000;">2</span><span style="color: #339933;">,</span> <span style="color: #CC0000;">4</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">,</span><br />
&nbsp; <span style="color: #009900;">&#91;</span><span style="color: #CC0000;">2</span><span style="color: #339933;">,</span> <span style="color: #CC0000;">3</span><span style="color: #339933;">,</span> <span style="color: #CC0000;">2</span><span style="color: #339933;">,</span> <span style="color: #CC0000;">2</span><span style="color: #339933;">,</span> <span style="color: #CC0000;">3</span><span style="color: #339933;">,</span> <span style="color: #CC0000;">2</span><span style="color: #339933;">,</span> <span style="color: #CC0000;">3</span><span style="color: #339933;">,</span> <span style="color: #CC0000;">4</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">,</span><br />
&nbsp; <span style="color: #009900;">&#91;</span><span style="color: #CC0000;">3</span><span style="color: #339933;">,</span> <span style="color: #CC0000;">4</span><span style="color: #339933;">,</span> <span style="color: #CC0000;">4</span><span style="color: #339933;">,</span> <span style="color: #CC0000;">3</span><span style="color: #339933;">,</span> <span style="color: #CC0000;">2</span><span style="color: #339933;">,</span> <span style="color: #CC0000;">4</span><span style="color: #339933;">,</span> <span style="color: #CC0000;">3</span><span style="color: #339933;">,</span> <span style="color: #CC0000;">2</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">,</span><br />
&nbsp; <span style="color: #009900;">&#91;</span><span style="color: #CC0000;">4</span><span style="color: #339933;">,</span> <span style="color: #CC0000;">2</span><span style="color: #339933;">,</span> <span style="color: #CC0000;">3</span><span style="color: #339933;">,</span> <span style="color: #CC0000;">3</span><span style="color: #339933;">,</span> <span style="color: #CC0000;">2</span><span style="color: #339933;">,</span> <span style="color: #CC0000;">4</span><span style="color: #339933;">,</span> <span style="color: #CC0000;">2</span><span style="color: #339933;">,</span> <span style="color: #CC0000;">4</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">,</span><br />
&nbsp; <span style="color: #009900;">&#91;</span><span style="color: #CC0000;">2</span><span style="color: #339933;">,</span> <span style="color: #CC0000;">3</span><span style="color: #339933;">,</span> <span style="color: #CC0000;">2</span><span style="color: #339933;">,</span> <span style="color: #CC0000;">2</span><span style="color: #339933;">,</span> <span style="color: #CC0000;">1</span><span style="color: #339933;">,</span> <span style="color: #CC0000;">3</span><span style="color: #339933;">,</span> <span style="color: #CC0000;">2</span><span style="color: #339933;">,</span> <span style="color: #CC0000;">2</span><span style="color: #009900;">&#93;</span><br />
<span style="color: #009900;">&#93;</span><span style="color: #339933;">;</span><br />
b <span style="color: #339933;">=</span> <span style="color: #009900;">&#91;</span><br />
&nbsp; <span style="color: #CC0000;">26</span><span style="color: #339933;">,</span><br />
&nbsp; <span style="color: #CC0000;">13</span><span style="color: #339933;">,</span><br />
&nbsp; <span style="color: #CC0000;">0</span><span style="color: #339933;">,</span><br />
&nbsp; <span style="color: #CC0000;">20</span><span style="color: #339933;">,</span><br />
&nbsp; <span style="color: #CC0000;">5</span><span style="color: #339933;">,</span><br />
&nbsp; <span style="color: #CC0000;">5</span><span style="color: #339933;">,</span><br />
&nbsp; <span style="color: #CC0000;">17</span><span style="color: #339933;">,</span><br />
&nbsp; <span style="color: #339933;">-</span><span style="color: #CC0000;">6</span><br />
<span style="color: #009900;">&#93;</span><span style="color: #339933;">;</span><br />
x <span style="color: #339933;">=</span> math.<span style="color: #660066;">lusolve</span><span style="color: #009900;">&#40;</span>A<span style="color: #339933;">,</span> b<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
console.<span style="color: #660066;">log</span><span style="color: #009900;">&#40;</span>x<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></div></div>
<p>実行結果</p>
<p>[<br />
[8.000000000000004],<br />
[-6.999999999999997],<br />
[5.9999999999999964],<br />
[-5],<br />
[4],<br />
[-3.000000000000001],<br />
[1.9999999999999991],<br />
[-1.0000000000000007]<br />
]</p>
]]></content:encoded>
					
					<wfw:commentRss>https://stabucky.com/wp/archives/16052/feed</wfw:commentRss>
			<slash:comments>1</slash:comments>
		
		
			</item>
	</channel>
</rss>
