-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathjavascript-stack.htm
262 lines (239 loc) · 34.8 KB
/
javascript-stack.htm
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
<!DOCTYPE html><html lang="zh-CN" data-theme="light"><head><meta charset="UTF-8"><meta http-equiv="X-UA-Compatible" content="IE=edge"><meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no"><title>javascript_stack | Anthony's Blog</title><meta name="keywords" content="代码,JavaScript,算法,栈"><meta name="author" content="HaoDong Wu"><meta name="copyright" content="HaoDong Wu"><meta name="format-detection" content="telephone=no"><meta name="theme-color" content="#ffffff"><meta name="description" content="js的数据结构一:栈">
<meta property="og:type" content="article">
<meta property="og:title" content="javascript_stack">
<meta property="og:url" content="https://www.scery.com/javascript-stack.htm">
<meta property="og:site_name" content="Anthony's Blog">
<meta property="og:description" content="js的数据结构一:栈">
<meta property="og:locale" content="zh_CN">
<meta property="og:image" content="data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7">
<meta property="article:published_time" content="2020-04-28T12:34:39.000Z">
<meta property="article:modified_time" content="2024-03-18T02:51:00.812Z">
<meta property="article:author" content="HaoDong Wu">
<meta property="article:tag" content="代码">
<meta property="article:tag" content="JavaScript">
<meta property="article:tag" content="算法">
<meta property="article:tag" content="栈">
<meta name="twitter:card" content="summary">
<meta name="twitter:image" content="data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7"><link rel="shortcut icon" href="/img/avatar.png"><link rel="canonical" href="https://www.scery.com/javascript-stack.htm"><link rel="preconnect" href="//cdn.jsdelivr.net"/><link rel="preconnect" href="//busuanzi.ibruce.info"/><meta name="baidu-site-verification" content="code-cOpY18SESu"/><link rel="stylesheet" href="css/index.css"><link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/@fortawesome/fontawesome-free/css/all.min.css" media="print" onload="this.media='all'"><link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/@fancyapps/ui/dist/fancybox.min.css" media="print" onload="this.media='all'"><script>const GLOBAL_CONFIG = {
root: '/',
algolia: undefined,
localSearch: {"path":"/search.xml","preload":true,"languages":{"hits_empty":"找不到您查询的内容:${query}"}},
translate: undefined,
noticeOutdate: undefined,
highlight: {"plugin":"highlighjs","highlightCopy":true,"highlightLang":true,"highlightHeightLimit":false},
copy: {
success: '复制成功',
error: '复制错误',
noSupport: '浏览器不支持'
},
relativeDate: {
homepage: false,
post: false
},
runtime: '天',
date_suffix: {
just: '刚刚',
min: '分钟前',
hour: '小时前',
day: '天前',
month: '个月前'
},
copyright: undefined,
lightbox: 'fancybox',
Snackbar: undefined,
source: {
justifiedGallery: {
js: 'https://cdn.jsdelivr.net/npm/flickr-justified-gallery/dist/fjGallery.min.js',
css: 'https://cdn.jsdelivr.net/npm/flickr-justified-gallery/dist/fjGallery.min.css'
}
},
isPhotoFigcaption: false,
islazyload: false,
isAnchor: true
}</script><script id="config-diff">var GLOBAL_CONFIG_SITE = {
title: 'javascript_stack',
isPost: true,
isHome: false,
isHighlightShrink: false,
isToc: true,
postUpdate: '2024-03-18 10:51:00'
}</script><noscript><style type="text/css">
#nav {
opacity: 1
}
.justified-gallery img {
opacity: 1
}
#recent-posts time,
#post-meta time {
display: inline !important
}
</style></noscript><script>(win=>{
win.saveToLocal = {
set: function setWithExpiry(key, value, ttl) {
if (ttl === 0) return
const now = new Date()
const expiryDay = ttl * 86400000
const item = {
value: value,
expiry: now.getTime() + expiryDay,
}
localStorage.setItem(key, JSON.stringify(item))
},
get: function getWithExpiry(key) {
const itemStr = localStorage.getItem(key)
if (!itemStr) {
return undefined
}
const item = JSON.parse(itemStr)
const now = new Date()
if (now.getTime() > item.expiry) {
localStorage.removeItem(key)
return undefined
}
return item.value
}
}
win.getScript = url => new Promise((resolve, reject) => {
const script = document.createElement('script')
script.src = url
script.async = true
script.onerror = reject
script.onload = script.onreadystatechange = function() {
const loadState = this.readyState
if (loadState && loadState !== 'loaded' && loadState !== 'complete') return
script.onload = script.onreadystatechange = null
resolve()
}
document.head.appendChild(script)
})
win.activateDarkMode = function () {
document.documentElement.setAttribute('data-theme', 'dark')
if (document.querySelector('meta[name="theme-color"]') !== null) {
document.querySelector('meta[name="theme-color"]').setAttribute('content', '#0d0d0d')
}
}
win.activateLightMode = function () {
document.documentElement.setAttribute('data-theme', 'light')
if (document.querySelector('meta[name="theme-color"]') !== null) {
document.querySelector('meta[name="theme-color"]').setAttribute('content', '#ffffff')
}
}
const t = saveToLocal.get('theme')
if (t === 'dark') activateDarkMode()
else if (t === 'light') activateLightMode()
const asideStatus = saveToLocal.get('aside-status')
if (asideStatus !== undefined) {
if (asideStatus === 'hide') {
document.documentElement.classList.add('hide-aside')
} else {
document.documentElement.classList.remove('hide-aside')
}
}
const detectApple = () => {
if(/iPad|iPhone|iPod|Macintosh/.test(navigator.userAgent)){
document.documentElement.classList.add('apple')
}
}
detectApple()
})(window)</script><meta name="generator" content="Hexo 5.4.2"><link rel="alternate" href="atom.xml" title="Anthony's Blog" type="application/atom+xml">
</head><body><div id="loading-box"><div class="loading-left-bg"></div><div class="loading-right-bg"></div><div class="spinner-box"><div class="configure-border-1"><div class="configure-core"></div></div><div class="configure-border-2"><div class="configure-core"></div></div><div class="loading-word">加载中...</div></div></div><div id="sidebar"><div id="menu-mask"></div><div id="sidebar-menus"><div class="avatar-img is-center"><img src="../img/avatar.png" onerror="onerror=null;src='/img/friend_404.gif'" alt="avatar"/></div><div class="sidebar-site-data site-data is-center"><a href="../archives/"><div class="headline">文章</div><div class="length-num">61</div></a><a href="../tags/"><div class="headline">标签</div><div class="length-num">58</div></a><a href="/"><div class="headline">分类</div><div class="length-num">61</div></a></div><hr/><div class="menus_items"><div class="menus_item"><a class="site-page" href="../index.html"><i class="fa-fw fas fa-home"></i><span> Home</span></a></div><div class="menus_item"><a class="site-page" href="../archives/"><i class="fa-fw fas fa-archive"></i><span> Archives</span></a></div><div class="menus_item"><a class="site-page" href="../tags/"><i class="fa-fw fas fa-tags"></i><span> Tags</span></a></div><div class="menus_item"><a class="site-page" href="../categories/"><i class="fa-fw fas fa-folder-open"></i><span> Categories</span></a></div><div class="menus_item"><a class="site-page" href="../links/"><i class="fa-fw fas fa-link"></i><span> Link</span></a></div><div class="menus_item"><a class="site-page" href="../about/"><i class="fa-fw fas fa-heart"></i><span> About</span></a></div></div></div></div><div class="post" id="body-wrap"><header class="post-bg" id="page-header" style="background-image: url('data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP/yH5BAEAAAAALAAAAAABAAEAAAIBRAA7')"><nav id="nav"><span id="blog_name"><a id="site-name" href="../index.html">Anthony's Blog</a></span><div id="menus"><div id="search-button"><a class="site-page social-icon search"><i class="fas fa-search fa-fw"></i><span> 搜索</span></a></div><div class="menus_items"><div class="menus_item"><a class="site-page" href="../index.html"><i class="fa-fw fas fa-home"></i><span> Home</span></a></div><div class="menus_item"><a class="site-page" href="../archives/"><i class="fa-fw fas fa-archive"></i><span> Archives</span></a></div><div class="menus_item"><a class="site-page" href="../tags/"><i class="fa-fw fas fa-tags"></i><span> Tags</span></a></div><div class="menus_item"><a class="site-page" href="../categories/"><i class="fa-fw fas fa-folder-open"></i><span> Categories</span></a></div><div class="menus_item"><a class="site-page" href="../links/"><i class="fa-fw fas fa-link"></i><span> Link</span></a></div><div class="menus_item"><a class="site-page" href="../about/"><i class="fa-fw fas fa-heart"></i><span> About</span></a></div></div><div id="toggle-menu"><a class="site-page"><i class="fas fa-bars fa-fw"></i></a></div></div></nav><div id="post-info"><h1 class="post-title">javascript_stack</h1><div id="post-meta"><div class="meta-firstline"><span class="post-meta-date"><i class="far fa-calendar-alt fa-fw post-meta-icon"></i><span class="post-meta-label">发表于</span><time class="post-meta-date-created" datetime="2020-04-28T12:34:39.000Z" title="发表于 2020-04-28 20:34:39">2020-04-28</time><span class="post-meta-separator">|</span><i class="fas fa-history fa-fw post-meta-icon"></i><span class="post-meta-label">更新于</span><time class="post-meta-date-updated" datetime="2024-03-18T02:51:00.812Z" title="更新于 2024-03-18 10:51:00">2024-03-18</time></span><span class="post-meta-categories"><span class="post-meta-separator">|</span><i class="fas fa-inbox fa-fw post-meta-icon"></i><a class="post-meta-categories" href="categories/%E4%BB%A3%E7%A0%81/">代码</a><i class="fas fa-angle-right post-meta-separator"></i><i class="fas fa-inbox fa-fw post-meta-icon"></i><a class="post-meta-categories" href="categories/%E4%BB%A3%E7%A0%81/JavaScript/">JavaScript</a><i class="fas fa-angle-right post-meta-separator"></i><i class="fas fa-inbox fa-fw post-meta-icon"></i><a class="post-meta-categories" href="categories/%E4%BB%A3%E7%A0%81/JavaScript/%E7%AE%97%E6%B3%95/">算法</a><i class="fas fa-angle-right post-meta-separator"></i><i class="fas fa-inbox fa-fw post-meta-icon"></i><a class="post-meta-categories" href="categories/%E4%BB%A3%E7%A0%81/JavaScript/%E7%AE%97%E6%B3%95/%E6%A0%88/">栈</a></span></div><div class="meta-secondline"><span class="post-meta-separator">|</span><span class="post-meta-wordcount"><i class="far fa-file-word fa-fw post-meta-icon"></i><span class="post-meta-label">字数总计:</span><span class="word-count">254</span><span class="post-meta-separator">|</span><i class="far fa-clock fa-fw post-meta-icon"></i><span class="post-meta-label">阅读时长:</span><span>1分钟</span></span><span class="post-meta-separator">|</span><span class="post-meta-pv-cv" id="" data-flag-title="javascript_stack"><i class="far fa-eye fa-fw post-meta-icon"></i><span class="post-meta-label">阅读量:</span><span id="busuanzi_value_page_pv"><i class="fa-solid fa-spinner fa-spin"></i></span></span></div></div></div></header><main class="layout" id="content-inner"><div id="post"><article class="post-content" id="article-container"><h1 id="栈"><a href="#栈" class="headerlink" title="栈"></a>栈</h1><h4 id="栈是什么"><a href="#栈是什么" class="headerlink" title="栈是什么?"></a>栈是什么?</h4><p><img src="https://pic-1257960926.cos.ap-guangzhou.myqcloud.com/blog/image-20200428222025214.png" alt="image-20200428222025214"></p>
<h4 id="我们要实现的是"><a href="#我们要实现的是" class="headerlink" title="我们要实现的是:"></a>我们要实现的是:</h4><p><img src="https://pic-1257960926.cos.ap-guangzhou.myqcloud.com/blog/image-20200428222538650.png" alt="image-20200428222538650"></p>
<h3 id="先建立一个Html引入js"><a href="#先建立一个Html引入js" class="headerlink" title="先建立一个Html引入js"></a>先建立一个Html引入js</h3><figure class="highlight html"><table><tr><td class="code"><pre><span class="line"><span class="meta"><!DOCTYPE <span class="keyword">html</span>></span></span><br><span class="line"><span class="tag"><<span class="name">html</span> <span class="attr">lang</span>=<span class="string">"en"</span>></span></span><br><span class="line"><span class="tag"><<span class="name">head</span>></span></span><br><span class="line"> <span class="tag"><<span class="name">meta</span> <span class="attr">charset</span>=<span class="string">"UTF-8"</span>></span></span><br><span class="line"> <span class="tag"><<span class="name">meta</span> <span class="attr">name</span>=<span class="string">"viewport"</span> <span class="attr">content</span>=<span class="string">"width=device-width, initial-scale=1.0"</span>></span></span><br><span class="line"> <span class="tag"><<span class="name">title</span>></span>TEST<span class="tag"></<span class="name">title</span>></span></span><br><span class="line"> <span class="tag"><<span class="name">script</span> <span class="attr">src</span>=<span class="string">"./01_栈.js"</span>></span><span class="tag"></<span class="name">script</span>></span></span><br><span class="line"><span class="tag"></<span class="name">head</span>></span></span><br><span class="line"><span class="tag"><<span class="name">body</span>></span></span><br><span class="line"><span class="tag"></<span class="name">body</span>></span></span><br><span class="line"><span class="tag"></<span class="name">html</span>></span></span><br></pre></td></tr></table></figure>
<h3 id="栈操作-js"><a href="#栈操作-js" class="headerlink" title="栈操作.js"></a>栈操作.js</h3><figure class="highlight javascript"><table><tr><td class="code"><pre><span class="line"><span class="comment">//栈的操作</span></span><br><span class="line"></span><br><span class="line"><span class="keyword">let</span> <span class="title class_">Stack</span> = <span class="keyword">function</span>(<span class="params"></span>){</span><br><span class="line"> <span class="keyword">let</span> arr = []</span><br><span class="line"></span><br><span class="line"> <span class="comment">//插入元素到栈底</span></span><br><span class="line"> <span class="variable language_">this</span>.<span class="property">push</span> = <span class="function">(<span class="params">element</span>)=></span> {</span><br><span class="line"> <span class="keyword">return</span> arr.<span class="title function_">push</span>(element)</span><br><span class="line"> }</span><br><span class="line"></span><br><span class="line"> <span class="comment">//拿出栈顶元素</span></span><br><span class="line"> <span class="variable language_">this</span>.<span class="property">pop</span> = <span class="function">()=></span>{</span><br><span class="line"> <span class="keyword">return</span> arr.<span class="title function_">pop</span>()</span><br><span class="line"> }</span><br><span class="line"></span><br><span class="line"> <span class="comment">//查看栈顶</span></span><br><span class="line"> <span class="variable language_">this</span>.<span class="property">peek</span> = <span class="function">()=></span>{</span><br><span class="line"> <span class="keyword">return</span> arr[arr.<span class="property">length</span> - <span class="number">1</span>]</span><br><span class="line"> }</span><br><span class="line"></span><br><span class="line"> <span class="comment">//是否为空栈</span></span><br><span class="line"> <span class="variable language_">this</span>.<span class="property">isEmpty</span> = <span class="function">()=></span>{</span><br><span class="line"> <span class="keyword">return</span> arr.<span class="property">length</span> == <span class="number">0</span></span><br><span class="line"> }</span><br><span class="line"></span><br><span class="line"> <span class="comment">//清空栈</span></span><br><span class="line"> <span class="variable language_">this</span>.<span class="property">clear</span> = <span class="function">()=></span>{</span><br><span class="line"> arr = []</span><br><span class="line"> }</span><br><span class="line"> </span><br><span class="line"> <span class="comment">//查看栈所有元素</span></span><br><span class="line"> <span class="variable language_">this</span>.<span class="property">getAll</span> = <span class="function">()=></span>{</span><br><span class="line"> <span class="keyword">return</span> arr</span><br><span class="line"> }</span><br><span class="line"></span><br><span class="line"> <span class="comment">//查看栈元素数量</span></span><br><span class="line"> <span class="variable language_">this</span>.<span class="property">size</span> = <span class="function">()=></span>{</span><br><span class="line"> <span class="keyword">return</span> arr.<span class="property">length</span>;</span><br><span class="line"> }</span><br><span class="line">}</span><br><span class="line"></span><br><span class="line"></span><br></pre></td></tr></table></figure>
<h3 id="实际应用"><a href="#实际应用" class="headerlink" title="实际应用:"></a>实际应用:</h3><h5 id="十进制转二进制"><a href="#十进制转二进制" class="headerlink" title="十进制转二进制"></a><u><strong>十进制转二进制</strong></u></h5><figure class="highlight javascript"><table><tr><td class="code"><pre><span class="line"><span class="keyword">let</span> <span class="title class_">TtoT</span> = <span class="keyword">function</span>(<span class="params">numbers</span>){</span><br><span class="line"> <span class="keyword">var</span> stack = <span class="keyword">new</span> <span class="title class_">Stack</span>()</span><br><span class="line"> <span class="keyword">let</span> result = <span class="string">""</span></span><br><span class="line"> <span class="keyword">while</span>(numbers><span class="number">0</span>){</span><br><span class="line"> <span class="keyword">let</span> temp = numbers % <span class="number">2</span></span><br><span class="line"> stack.<span class="title function_">push</span>(temp)</span><br><span class="line"> numbers = (numbers/<span class="number">2</span>)|<span class="number">0</span></span><br><span class="line"> }</span><br><span class="line"> <span class="keyword">while</span>(!stack.<span class="title function_">isEmpty</span>()){</span><br><span class="line"> result+=stack.<span class="title function_">pop</span>()</span><br><span class="line"> }</span><br><span class="line"> <span class="keyword">return</span> result</span><br><span class="line">}</span><br></pre></td></tr></table></figure>
</article><div class="post-copyright"><div class="post-copyright__author"><span class="post-copyright-meta">文章作者: </span><span class="post-copyright-info"><a href="https://www.scery.com">HaoDong Wu</a></span></div><div class="post-copyright__type"><span class="post-copyright-meta">文章链接: </span><span class="post-copyright-info"><a href="https://www.scery.com/javascript-stack.htm">https://www.scery.com/javascript-stack.htm</a></span></div><div class="post-copyright__notice"><span class="post-copyright-meta">版权声明: </span><span class="post-copyright-info">本博客所有文章除特别声明外,均采用 <a href="https://creativecommons.org/licenses/by-nc-sa/4.0/" target="_blank">CC BY-NC-SA 4.0</a> 许可协议。转载请注明来自 <a href="https://www.scery.com" target="_blank">Anthony's Blog</a>!</span></div></div><div class="tag_share"><div class="post-meta__tag-list"><a class="post-meta__tags" href="tags/%E4%BB%A3%E7%A0%81/">代码</a><a class="post-meta__tags" href="tags/JavaScript/">JavaScript</a><a class="post-meta__tags" href="tags/%E7%AE%97%E6%B3%95/">算法</a><a class="post-meta__tags" href="tags/%E6%A0%88/">栈</a></div><div class="post_share"><div class="social-share" data-image="data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP/yH5BAEAAAAALAAAAAABAAEAAAIBRAA7" data-sites="facebook,twitter,wechat,weibo,qq"></div><link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/butterfly-extsrc/sharejs/dist/css/share.min.css" media="print" onload="this.media='all'"><script src="https://cdn.jsdelivr.net/npm/butterfly-extsrc/sharejs/dist/js/social-share.min.js" defer></script></div></div><nav class="pagination-post" id="pagination"><div class="prev-post pull-left"><a href="javascript-queue.htm"><img class="prev-cover" src="data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP/yH5BAEAAAAALAAAAAABAAEAAAIBRAA7" onerror="onerror=null;src='/img/404.jpg'" alt="cover of previous post"><div class="pagination-info"><div class="label">上一篇</div><div class="prev_info">javascript-queue</div></div></a></div><div class="next-post pull-right"><a href="nmap%E7%9A%84%E5%91%BD%E4%BB%A4%E8%AF%A6%E8%A7%A3.htm"><img class="next-cover" src="data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP/yH5BAEAAAAALAAAAAABAAEAAAIBRAA7" onerror="onerror=null;src='/img/404.jpg'" alt="cover of next post"><div class="pagination-info"><div class="label">下一篇</div><div class="next_info">nmap的命令详解</div></div></a></div></nav><div class="relatedPosts"><div class="headline"><i class="fas fa-thumbs-up fa-fw"></i><span>相关推荐</span></div><div class="relatedPosts-list"><div><a href="JavaScript%E6%95%B0%E6%8D%AE%E7%BB%93%E6%9E%84%E4%B8%8E%E7%AE%97%E6%B3%95%E6%8F%8F%E8%BF%B0.htm" title="javascript-data_tructures_and_algorithms"><img class="cover" src="data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP/yH5BAEAAAAALAAAAAABAAEAAAIBRAA7" alt="cover"><div class="content is-center"><div class="date"><i class="far fa-calendar-alt fa-fw"></i> 2020-06-05</div><div class="title">javascript-data_tructures_and_algorithms</div></div></a></div><div><a href="javascript-Double-linkedlist.htm" title="javascript-Double_linkedlist"><img class="cover" src="data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP/yH5BAEAAAAALAAAAAABAAEAAAIBRAA7" alt="cover"><div class="content is-center"><div class="date"><i class="far fa-calendar-alt fa-fw"></i> 2020-05-05</div><div class="title">javascript-Double_linkedlist</div></div></a></div><div><a href="javascript-circular-linkedlist.htm" title="javascript-circular-linkedlist"><img class="cover" src="data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP/yH5BAEAAAAALAAAAAABAAEAAAIBRAA7" alt="cover"><div class="content is-center"><div class="date"><i class="far fa-calendar-alt fa-fw"></i> 2020-05-09</div><div class="title">javascript-circular-linkedlist</div></div></a></div><div><a href="javascript-gather.htm" title="javascript-gather"><img class="cover" src="data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP/yH5BAEAAAAALAAAAAABAAEAAAIBRAA7" alt="cover"><div class="content is-center"><div class="date"><i class="far fa-calendar-alt fa-fw"></i> 2020-05-09</div><div class="title">javascript-gather</div></div></a></div><div><a href="javascript-linkedlist.htm" title="javascript-linkedlist"><img class="cover" src="data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP/yH5BAEAAAAALAAAAAABAAEAAAIBRAA7" alt="cover"><div class="content is-center"><div class="date"><i class="far fa-calendar-alt fa-fw"></i> 2020-04-29</div><div class="title">javascript-linkedlist</div></div></a></div><div><a href="javascript-queue.htm" title="javascript-queue"><img class="cover" src="data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP/yH5BAEAAAAALAAAAAABAAEAAAIBRAA7" alt="cover"><div class="content is-center"><div class="date"><i class="far fa-calendar-alt fa-fw"></i> 2020-04-29</div><div class="title">javascript-queue</div></div></a></div></div></div><hr/><div id="post-comment"><div class="comment-head"><div class="comment-headline"><i class="fas fa-comments fa-fw"></i><span> 评论</span></div></div><div class="comment-wrap"><div><div id="gitalk-container"></div></div></div></div></div><div class="aside-content" id="aside-content"><div class="card-widget card-info"><div class="is-center"><div class="avatar-img"><img src="../img/avatar.png" onerror="this.onerror=null;this.src='../img/friend_404.gif'" alt="avatar"/></div><div class="author-info__name">HaoDong Wu</div><div class="author-info__description">Email: [email protected]</div></div><div class="card-info-data site-data is-center"><a href="../archives/"><div class="headline">文章</div><div class="length-num">61</div></a><a href="../tags/"><div class="headline">标签</div><div class="length-num">58</div></a><a href="/"><div class="headline">分类</div><div class="length-num">61</div></a></div><a id="card-info-btn" target="_blank" rel="noopener" href="https://github.com/Anthonyfhd"><i class="fab fa-github"></i><span>Follow Me</span></a><div class="card-info-social-icons is-center"><a class="social-icon" href="https://github.com/Anthonyfhd" target="_blank" title="Github"><i class="fab fa-github"></i></a><a class="social-icon" href="../wuhaodong:[email protected]" target="_blank" title="Email"><i class="fas fa-envelope"></i></a><a class="social-icon" href="https://weibo.com/u/5730157238" target="_blank" title="z"><i class="fab fa-weibo"></i></a></div></div><div class="card-widget card-announcement"><div class="item-headline"><i class="fas fa-bullhorn fa-shake"></i><span>公告</span></div><div class="announcement_content">I am a slow walker,but I never walk backwards.</div></div><div class="sticky_layout"><div class="card-widget" id="card-toc"><div class="item-headline"><i class="fas fa-stream"></i><span>目录</span><span class="toc-percentage"></span></div><div class="toc-content"><ol class="toc"><li class="toc-item toc-level-1"><a class="toc-link" href="#%E6%A0%88"><span class="toc-number">1.</span> <span class="toc-text">栈</span></a><ol class="toc-child"><li class="toc-item toc-level-4"><a class="toc-link" href="#%E6%A0%88%E6%98%AF%E4%BB%80%E4%B9%88"><span class="toc-number">1.0.0.1.</span> <span class="toc-text">栈是什么?</span></a></li><li class="toc-item toc-level-4"><a class="toc-link" href="#%E6%88%91%E4%BB%AC%E8%A6%81%E5%AE%9E%E7%8E%B0%E7%9A%84%E6%98%AF"><span class="toc-number">1.0.0.2.</span> <span class="toc-text">我们要实现的是:</span></a></li></ol></li><li class="toc-item toc-level-3"><a class="toc-link" href="#%E5%85%88%E5%BB%BA%E7%AB%8B%E4%B8%80%E4%B8%AAHtml%E5%BC%95%E5%85%A5js"><span class="toc-number">1.0.1.</span> <span class="toc-text">先建立一个Html引入js</span></a></li><li class="toc-item toc-level-3"><a class="toc-link" href="#%E6%A0%88%E6%93%8D%E4%BD%9C-js"><span class="toc-number">1.0.2.</span> <span class="toc-text">栈操作.js</span></a></li><li class="toc-item toc-level-3"><a class="toc-link" href="#%E5%AE%9E%E9%99%85%E5%BA%94%E7%94%A8"><span class="toc-number">1.0.3.</span> <span class="toc-text">实际应用:</span></a><ol class="toc-child"><li class="toc-item toc-level-5"><a class="toc-link" href="#%E5%8D%81%E8%BF%9B%E5%88%B6%E8%BD%AC%E4%BA%8C%E8%BF%9B%E5%88%B6"><span class="toc-number">1.0.3.0.1.</span> <span class="toc-text">十进制转二进制</span></a></li></ol></li></ol></li></ol></li></ol></li></ol></div></div><div class="card-widget card-recent-post"><div class="item-headline"><i class="fas fa-history"></i><span>最新文章</span></div><div class="aside-list"><div class="aside-list-item no-cover"><div class="content"><a class="title" href="../XT20%E4%BD%BF%E7%94%A8%E6%96%B0%E6%9C%BA%E5%9E%8B%E7%9A%84%E9%A2%84%E8%AE%BE.htm" title="无题">无题</a><time datetime="2025-01-04T04:30:41.696Z" title="发表于 2025-01-04 12:30:41">2025-01-04</time></div></div><div class="aside-list-item no-cover"><div class="content"><a class="title" href="../%E7%BB%84%E4%BC%9A/20241223%E7%BB%84%E4%BC%9A.htm" title="20241223组会">20241223组会</a><time datetime="2024-12-23T06:56:00.000Z" title="发表于 2024-12-23 14:56:00">2024-12-23</time></div></div><div class="aside-list-item no-cover"><div class="content"><a class="title" href="../%E7%B2%BE%E5%87%86%E5%9B%BD%E9%99%85%E4%BC%A0%E6%92%AD%E7%B3%BB%E7%BB%9F/%E7%B2%BE%E4%BC%A0%E7%B3%BB%E7%BB%9F%E9%A1%B5%E9%9D%A2%E6%9D%83%E9%99%90%E9%85%8D%E7%BD%AE.htm" title="精传系统页面权限配置">精传系统页面权限配置</a><time datetime="2024-12-16T00:48:25.000Z" title="发表于 2024-12-16 08:48:25">2024-12-16</time></div></div><div class="aside-list-item no-cover"><div class="content"><a class="title" href="../%E5%B2%B3%E9%BA%93%E5%B1%B1%E6%95%B0%E6%99%BA%E4%BC%A0%E6%92%AD%E5%AE%9E%E9%AA%8C%E5%AE%A4/%E5%B2%B3%E9%BA%93%E5%B1%B1%E6%95%B0%E6%99%BA%E4%BC%A0%E6%92%AD%201.htm" title="岳麓山数智传播 1">岳麓山数智传播 1</a><time datetime="2024-12-15T08:54:00.000Z" title="发表于 2024-12-15 16:54:00">2024-12-15</time></div></div><div class="aside-list-item no-cover"><div class="content"><a class="title" href="../%E5%B2%B3%E9%BA%93%E5%B1%B1%E6%95%B0%E6%99%BA%E4%BC%A0%E6%92%AD%E5%AE%9E%E9%AA%8C%E5%AE%A4/%E5%B2%B3%E9%BA%93%E5%B1%B1%E6%95%B0%E6%99%BA%E4%BC%A0%E6%92%AD.htm" title="岳麓山数智传播">岳麓山数智传播</a><time datetime="2024-12-12T07:10:00.000Z" title="发表于 2024-12-12 15:10:00">2024-12-12</time></div></div></div></div></div></div></main><footer id="footer"><div id="footer-wrap"><div class="copyright">©2020 - 2025 By HaoDong Wu</div><div class="framework-info"></div><div class="beian"><a href="https://beian.miit.gov.cn/" rel="noopener" target="_blank">粤ICP备2024239461号 </a>
<img src="/images/beian.png" style="display: inline-block;"><a href="http://www.beian.gov.cn/portal/registerSystemInfo?recordcode=none" rel="noopener" target="_blank">粤公网安备号 </a>
</div></div></footer></div><div id="rightside"><div id="rightside-config-hide"><button id="readmode" type="button" title="阅读模式"><i class="fas fa-book-open"></i></button><button id="darkmode" type="button" title="浅色和深色模式转换"><i class="fas fa-adjust"></i></button><button id="hide-aside-btn" type="button" title="单栏和双栏切换"><i class="fas fa-arrows-alt-h"></i></button></div><div id="rightside-config-show"><button id="rightside_config" type="button" title="设置"><i class="fas fa-cog fa-spin"></i></button><button class="close" id="mobile-toc-button" type="button" title="目录"><i class="fas fa-list-ul"></i></button><a id="to_comment" href="#post-comment" title="直达评论"><i class="fas fa-comments"></i></a><button id="go-up" type="button" title="回到顶部"><i class="fas fa-arrow-up"></i></button></div></div><div id="local-search"><div class="search-dialog"><nav class="search-nav"><span class="search-dialog-title">搜索</span><span id="loading-status"></span><button class="search-close-button"><i class="fas fa-times"></i></button></nav><div class="is-center" id="loading-database"><i class="fas fa-spinner fa-pulse"></i><span> 数据库加载中</span></div><div class="search-wrap"><div id="local-search-input"><div class="local-search-box"><input class="local-search-box--input" placeholder="搜索文章" type="text"/></div></div><hr/><div id="local-search-results"></div></div></div><div id="search-mask"></div></div><div><script src="js/utils.js"></script><script src="js/main.js"></script><script src="https://cdn.jsdelivr.net/npm/@fancyapps/ui/dist/fancybox.umd.min.js"></script><script src="https://cdn.jsdelivr.net/npm/instant.page/instantpage.min.js" type="module"></script><script src="js/search/local-search.js"></script><script>var preloader = {
endLoading: () => {
document.body.style.overflow = 'auto';
document.getElementById('loading-box').classList.add("loaded")
},
initLoading: () => {
document.body.style.overflow = '';
document.getElementById('loading-box').classList.remove("loaded")
}
}
window.addEventListener('load',preloader.endLoading())</script><div class="js-pjax"><script>if (!window.MathJax) {
window.MathJax = {
tex: {
inlineMath: [ ['$','$'], ["\\(","\\)"]],
tags: 'ams'
},
chtml: {
scale: 1.2
},
options: {
renderActions: {
findScript: [10, doc => {
for (const node of document.querySelectorAll('script[type^="math/tex"]')) {
const display = !!node.type.match(/; *mode=display/)
const math = new doc.options.MathItem(node.textContent, doc.inputJax[0], display)
const text = document.createTextNode('')
node.parentNode.replaceChild(text, node)
math.start = {node: text, delim: '', n: 0}
math.end = {node: text, delim: '', n: 0}
doc.math.push(math)
}
}, ''],
insertScript: [200, () => {
document.querySelectorAll('mjx-container:not\([display]\)').forEach(node => {
const target = node.parentNode
if (target.nodeName.toLowerCase() === 'li') {
target.parentNode.classList.add('has-jax')
} else {
target.classList.add('has-jax')
}
});
}, '', false]
}
}
}
const script = document.createElement('script')
script.src = 'https://cdn.jsdelivr.net/npm/mathjax/es5/tex-mml-chtml.min.js'
script.id = 'MathJax-script'
script.async = true
document.head.appendChild(script)
} else {
MathJax.startup.document.state(0)
MathJax.texReset()
MathJax.typeset()
}</script><script>function addGitalkSource () {
const ele = document.createElement('link')
ele.rel = 'stylesheet'
ele.href= 'https://cdn.jsdelivr.net/npm/gitalk/dist/gitalk.min.css'
document.getElementsByTagName('head')[0].appendChild(ele)
}
function loadGitalk () {
function initGitalk () {
var gitalk = new Gitalk(Object.assign({
clientID: '85556d73db8de5db1c7f',
clientSecret: 'c62529657d2e66f49a40272e9aa404225a1952c3',
repo: 'Blog_GitTalk',
owner: 'Anthonyfhd',
admin: ['Anthonyfhd'],
id: 'd41d8cd98f00b204e9800998ecf8427e',
updateCountCallback: commentCount
},null))
gitalk.render('gitalk-container')
}
if (typeof Gitalk === 'function') initGitalk()
else {
addGitalkSource()
getScript('https://cdn.jsdelivr.net/npm/gitalk/dist/gitalk.min.js').then(initGitalk)
}
}
function commentCount(n){
let isCommentCount = document.querySelector('#post-meta .gitalk-comment-count')
if (isCommentCount) {
isCommentCount.innerHTML= n
}
}
if ('Gitalk' === 'Gitalk' || !true) {
if (true) btf.loadComment(document.getElementById('gitalk-container'), loadGitalk)
else loadGitalk()
} else {
function loadOtherComment () {
loadGitalk()
}
}</script></div><canvas class="fireworks" mobile="false"></canvas><script src="https://cdn.jsdelivr.net/npm/butterfly-extsrc/dist/fireworks.min.js"></script><script defer="defer" id="fluttering_ribbon" mobile="false" src="https://cdn.jsdelivr.net/npm/butterfly-extsrc/dist/canvas-fluttering-ribbon.min.js"></script><script async data-pjax src="//busuanzi.ibruce.info/busuanzi/2.3/busuanzi.pure.mini.js"></script></div></body></html>