<?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>nối chuỗi - Thien An Blog</title>
	<atom:link href="https://thienanblog.com/tag/noi-chuoi/feed/" rel="self" type="application/rss+xml" />
	<link>https://thienanblog.com/tag/noi-chuoi/</link>
	<description>Javascript - PHP - SEO - Web Development</description>
	<lastBuildDate>Mon, 25 May 2015 13:23:21 +0000</lastBuildDate>
	<language>en-US</language>
	<sy:updatePeriod>
	hourly	</sy:updatePeriod>
	<sy:updateFrequency>
	1	</sy:updateFrequency>
	<generator>https://wordpress.org/?v=6.7.1</generator>

<image>
	<url>https://thienanblog.com/wp-content/uploads/2017/05/TAB_favicon.ico.png</url>
	<title>nối chuỗi - Thien An Blog</title>
	<link>https://thienanblog.com/tag/noi-chuoi/</link>
	<width>32</width>
	<height>32</height>
</image> 
	<item>
		<title>Bài 3: Toán tử trong Javascript</title>
		<link>https://thienanblog.com/javascript/javascript-co-ban/bai-3-toan-tu-trong-javascript/</link>
					<comments>https://thienanblog.com/javascript/javascript-co-ban/bai-3-toan-tu-trong-javascript/#respond</comments>
		
		<dc:creator><![CDATA[Ân Vũ]]></dc:creator>
		<pubDate>Mon, 04 May 2015 11:26:51 +0000</pubDate>
				<category><![CDATA[Javascript cơ bản]]></category>
		<category><![CDATA[nối chuỗi]]></category>
		<category><![CDATA[toán học]]></category>
		<category><![CDATA[toán tử]]></category>
		<category><![CDATA[toán tử logic]]></category>
		<category><![CDATA[toán tử so sánh]]></category>
		<guid isPermaLink="false">https://thienanblog.com/?p=38</guid>

					<description><![CDATA[<p>Ở các bài học trước, chúng ta đã tìm hiểu về Kiểu dữ liệu và Phạm vi hoạt động của biến trong Javascript. Tiếp nối bài học này, các bạn&#8230;</p>
<p>The post <a href="https://thienanblog.com/javascript/javascript-co-ban/bai-3-toan-tu-trong-javascript/">Bài 3: Toán tử trong Javascript</a> appeared first on <a href="https://thienanblog.com">Thien An Blog</a>.</p>
]]></description>
										<content:encoded><![CDATA[<p style="text-align: center;">Ở các bài học trước, chúng ta đã tìm hiểu về <a href="https://thienanblog.com/javascript/javascript-co-ban/tim-hieu-kieu-du-lieu-trong-javascript/">Kiểu dữ liệu</a> và <a href="https://thienanblog.com/javascript/javascript-co-ban/bai-2-pham-vi-hoat-dong-cua-bien-trong-javascript/">Phạm vi hoạt động</a> của biến trong Javascript. Tiếp nối bài học này, các bạn sẽ được biết qua về Toán tử trong Javascript được quy ước như thế nào?</p>
<p><a href="https://thienanblog.com/wp-content/uploads/2015/05/matrix.jpg"><img fetchpriority="high" decoding="async" class="  aligncenter wp-image-43" title="Toán tử trong Javascript" src="https://thienanblog.com/wp-content/uploads/2015/05/matrix-1024x576.jpg" alt="Toán tử trong Javascript" width="604" height="340" srcset="https://thienanblog.com/wp-content/uploads/2015/05/matrix-1024x576.jpg 1024w, https://thienanblog.com/wp-content/uploads/2015/05/matrix-300x169.jpg 300w, https://thienanblog.com/wp-content/uploads/2015/05/matrix.jpg 1920w" sizes="(max-width: 604px) 100vw, 604px" /></a></p>
<p>&nbsp;</p>
<h2 style="text-align: center;">Toán tử trong Javascript</h2>
<p>&nbsp;</p>
<h2>Toán tử số học</h2>
<p><strong>(Vui lòng bật F12 trên Chrome/Firefox và chuyển sang Tab Console để thấy kết quả)</strong></p>
<pre class="lang:default decode:true">&lt;script type="text/javascript"&gt;
	var a = 10;
	var b = 15;
	var c = 20;
	var d = c - b * a / 2;
	console.log(d);
&lt;/script&gt;</pre>
<p>Kết quả:</p>
<pre class="lang:default highlight:0 decode:true">-55</pre>
<ul>
<li>Toán tử trong Javascript đều có sự tương đồng với các ngôn ngữ lập trình khác và vẫn tuân theo quy tắc toán học “Nhân chia trước, cộng trừ sau”.</li>
</ul>
<p><strong>Các bạn có thể xem chi tiết các toán tử của Javascript như sau:</strong></p>
<table>
<tbody>
<tr>
<td width="300">+</td>
<td width="300">Phép cộng</td>
</tr>
<tr>
<td width="300">&#8211;</td>
<td width="300">Phép trừ</td>
</tr>
<tr>
<td width="300">*</td>
<td width="300">Phép nhân</td>
</tr>
<tr>
<td width="300">/</td>
<td width="300">Phép chia</td>
</tr>
<tr>
<td width="300">%</td>
<td width="300">Phép chia lấy dư</td>
</tr>
</tbody>
</table>
<h2>Toán tử kết hợp</h2>
<table>
<tbody>
<tr>
<td width="200">Toán tử kết hợp</td>
<td width="200">Ví dụ viết tắt</td>
<td width="200">Ví dụ đầy đủ</td>
</tr>
<tr>
<td width="200">++</td>
<td width="200">a++</td>
<td width="200">a = a + 1</td>
</tr>
<tr>
<td width="200">&#8212;</td>
<td width="200">a&#8211;</td>
<td width="200">a = a – 1</td>
</tr>
<tr>
<td width="200">+=</td>
<td width="200">a += 2</td>
<td width="200">a = a + 2</td>
</tr>
<tr>
<td width="200">-=</td>
<td width="200">a -= 2</td>
<td width="200">a = a – 2</td>
</tr>
<tr>
<td width="200">*=</td>
<td width="200">a *= 2</td>
<td width="200">a = a * 2</td>
</tr>
<tr>
<td width="200">/=</td>
<td width="200">a /= 2</td>
<td width="200">a = a / 2</td>
</tr>
<tr>
<td width="200">%=</td>
<td width="200">a %= 2</td>
<td width="200">a = a % 2</td>
</tr>
</tbody>
</table>
<h2>Toán tử nối chuỗi (String)</h2>
<pre class="lang:default decode:true ">&lt;script type="text/javascript"&gt;
	var a = "Hello";
	var b = "World!";
	var c = a + " " + b;
	console.log();
&lt;/script&gt;</pre>
<p>Kết quả:</p>
<pre class="lang:default decode:true ">Hello World!</pre>
<ul>
<li>Sau khi thực hiện dòng lệnh như trên, bạn sẽ thấy cách nối chuỗi trong Javascript được thực hiện như thế nào. Thông qua việc sử dụng toán tử “+” để nối 2 chuỗi lại với nhau. Ở ví dụ bên trên còn cho chúng ta thấy được việc chúng ta không nhất thiết phải lưu trữ trong biến mới có thể nối chuỗi được mà chúng đã có thể viết chuỗi trực tiếp trong Javascript.</li>
</ul>
<h3><strong>Trường hợp ngoại lệ</strong></h3>
<pre class="lang:default decode:true ">&lt;script type="text/javascript"&gt;
	var a = "Hello" + 5;
	var b = "100" + 5;
	var c = 5 + 10 + "Hello";
	var d = 5 + "Hello" + 10;
	var e = "Hello" + 5 + 10;
	console.log(a);
	console.log(b);
	console.log(c);
	console.log(d);
	console.log(e);
&lt;/script&gt;</pre>
<p>Kết quả:</p>
<pre class="lang:default decode:true ">Hello5
1005
15Hello
5Hello10
Hello510</pre>
<ul>
<li>Qua 5 ví dụ đơn giản như trên, nếu như chúng ta sử dụng toán tử “+” theo thứ tự “Chuỗi + Số” thì số cũng sẽ được xem là chuỗi và nó sẽ thực hiện thao tác nối chuỗi như bình thường. Tuy nhiên ở ví dụ biến “c” chúng ta sẽ thấy được độ ưu tiên khi sử dụng toán tử là từ trái sang phải, nếu bên trái toán tử “+” và phải của toán tử “+” đều là số thì nó sẽ thực hiện phép tính trước và sau đó dùng toán tử “+” để nối chuỗi với chuỗi phía sau nó. Tương tự các ví dụ còn lại, các bạn hãy tự viết lại để nhìn nhận ra vấn đề rõ ràng hơn.</li>
</ul>
<h2><strong>Toán tử so sánh</strong></h2>
<table>
<tbody>
<tr>
<td width="300">&gt;</td>
<td width="300">Lớn hơn</td>
</tr>
<tr>
<td width="300">&lt;</td>
<td width="300">Nhỏ hơn</td>
</tr>
<tr>
<td width="300">&gt;=</td>
<td width="300">Lớn hơn hoặc bằng</td>
</tr>
<tr>
<td width="300">&lt;=</td>
<td width="300">Nhỏ hơn hoặc bằng</td>
</tr>
<tr>
<td width="300">==</td>
<td width="300">Bằng</td>
</tr>
<tr>
<td width="300">!=</td>
<td width="300">Không bằng</td>
</tr>
<tr>
<td width="300">===</td>
<td width="300">Bằng và giống kiểu dữ liệu</td>
</tr>
<tr>
<td width="300">!===</td>
<td width="300">Không bằng và không giống kiểu dữ liệu</td>
</tr>
</tbody>
</table>
<h2><strong>Toán tử Logic</strong></h2>
<table>
<tbody>
<tr>
<td width="200">Toán tử Logic</td>
<td width="200">True (Đúng)</td>
<td width="200">False (Sai)</td>
</tr>
<tr>
<td width="200">&amp;&amp;</td>
<td width="200">Cả 2 vế trái và phải đúng</td>
<td width="200">1 trong 2 vế trai hoặc phải sai</td>
</tr>
<tr>
<td width="200">||</td>
<td width="200">1 trong 2 vế trái hoặc phải đúng</td>
<td width="200">Cả 2 vế trái và phải sai</td>
</tr>
<tr>
<td width="200">!</td>
<td width="200">Phủ định của False</td>
<td width="200">Phủ định của True</td>
</tr>
</tbody>
</table>
<p>Trong bài này, &#8220;Toán tử so sánh&#8221; và &#8220;Toán tử Logic&#8221; các bạn nên tham khảo qua. Trong bài <a href="https://thienanblog.com/javascript/javascript-co-ban/bai-4-bieu-thuc-trong-javascript/">Biểu thức trong Javascript</a>, tôi sẽ nói tiếp về các biểu thức &#8220;If&#8230;Else&#8221;, &#8220;Switch&#8230;case&#8221;. Lúc đó các bạn sẽ dần hiểu rõ nó hơn.</p>
<p>The post <a href="https://thienanblog.com/javascript/javascript-co-ban/bai-3-toan-tu-trong-javascript/">Bài 3: Toán tử trong Javascript</a> appeared first on <a href="https://thienanblog.com">Thien An Blog</a>.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://thienanblog.com/javascript/javascript-co-ban/bai-3-toan-tu-trong-javascript/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
	</channel>
</rss>
