<?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>CodeProject &#8211; Sibeesh Passion</title>
	<atom:link href="https://mail.sibeeshpassion.com/category/codeproject/feed/" rel="self" type="application/rss+xml" />
	<link>https://mail.sibeeshpassion.com</link>
	<description>My passion towards life</description>
	<lastBuildDate>Wed, 02 Jun 2021 15:18:32 +0000</lastBuildDate>
	<language>en-US</language>
	<sy:updatePeriod>
	hourly	</sy:updatePeriod>
	<sy:updateFrequency>
	1	</sy:updateFrequency>
	<generator>https://wordpress.org/?v=6.9.4</generator>

<image>
	<url>/wp-content/uploads/2017/04/Sibeesh_Passion_Logo_Small.png</url>
	<title>CodeProject &#8211; Sibeesh Passion</title>
	<link>https://mail.sibeeshpassion.com</link>
	<width>32</width>
	<height>32</height>
</image> 
	<item>
		<title>How to Update Net Core 2.0 Application to 2.1 Version</title>
		<link>https://mail.sibeeshpassion.com/how-to-update-net-core-2-0-application-to-2-1-version/</link>
					<comments>https://mail.sibeeshpassion.com/how-to-update-net-core-2-0-application-to-2-1-version/#disqus_thread</comments>
		
		<dc:creator><![CDATA[SibeeshVenu]]></dc:creator>
		<pubDate>Sat, 26 May 2018 09:13:30 +0000</pubDate>
				<category><![CDATA[.NET]]></category>
		<category><![CDATA[Asp.Net Core]]></category>
		<category><![CDATA[CodeProject]]></category>
		<category><![CDATA[.Net Core]]></category>
		<category><![CDATA[Dot Net Core]]></category>
		<category><![CDATA[Dot Net Core 2.0 to 2.1]]></category>
		<category><![CDATA[Dot Net Core 2.0 Vs Dot Net Core 2.1]]></category>
		<guid isPermaLink="false">https://sibeeshpassion.com/?p=12868</guid>

					<description><![CDATA[[toc] Introduction Many of you might have been developing applications in Net Core 2.0 version, as that was the main release with lots of features. But did you know that the next big release has already happened with some additional features in Net Core journey? Have you already migrated your applications to Dot Net Core 2.1.x version already? If you haven&#8217;t, no worries, here in this post, we are going to cover talk about how we can migrate/update our applications to the new version of Dot Net Core. I hope you will like this article. Background As I said, this [&#8230;]]]></description>
										<content:encoded><![CDATA[<p>[toc]</p>
<h2>Introduction</h2>
<p>Many of you might have been developing applications in Net Core 2.0 version, as that was the main release with lots of features. But did you know that the next big release has already happened with some additional features in Net Core journey? Have you already migrated your applications to Dot Net Core 2.1.x version already? If you haven&#8217;t, no worries, here in this post, we are going to cover talk about how we can migrate/update our applications to the new version of Dot Net Core. I hope you will like this article.</p>
<h2>Background</h2>
<p>As I said, this post is only going to cover the steps you may have to take to update your existing Dot Net Core application to 2.1.x. And I will be not be talking about what is Dot net core? And why dot net core is important? etc, if you have those queries in your mind, I strongly recommend you to read the Microsoft document <a href="https://docs.microsoft.com/en-in/dotnet/core/">here</a>.</p>
<p>We will be creating a Dot net Core 2.0 application first, and then we will update the same to 2.1.x version. Sounds good?</p>
<h2>.Net Core 2.0 to 2.1.x</h2>
<h3>Let&#8217;s create a .net core 2.0 application</h3>
<p>As usual open your favorite IDE, Visual Studio 2017, Click on File -&gt; New Project</p>
<p><a href="https://sibeeshpassion.com/wp-content/uploads/2018/05/Net-Core-2.0.jpg"><img fetchpriority="high" decoding="async" class="alignnone wp-image-12869 size-full" src="https://sibeeshpassion.com/wp-content/uploads/2018/05/Net-Core-2.0.jpg" alt="" width="508" height="357" srcset="/wp-content/uploads/2018/05/Net-Core-2.0.jpg 508w, /wp-content/uploads/2018/05/Net-Core-2.0-300x211.jpg 300w, /wp-content/uploads/2018/05/Net-Core-2.0-768x540.jpg 768w, /wp-content/uploads/2018/05/Net-Core-2.0-400x281.jpg 400w, /wp-content/uploads/2018/05/Net-Core-2.0-853x600.jpg 853w" sizes="(max-width: 508px) 100vw, 508px" /></a></p>
<p>As you can see, Asp Net Core version is 2.0.</p>
<p>You can even check the version in your application properties.</p>
<p><a href="https://sibeeshpassion.com/wp-content/uploads/2018/05/Application-Menu.jpg"><img decoding="async" class="alignnone wp-image-12871" src="https://sibeeshpassion.com/wp-content/uploads/2018/05/Application-Menu.jpg" alt="" width="634" height="195" srcset="/wp-content/uploads/2018/05/Application-Menu.jpg 634w, /wp-content/uploads/2018/05/Application-Menu-300x92.jpg 300w, /wp-content/uploads/2018/05/Application-Menu-768x236.jpg 768w, /wp-content/uploads/2018/05/Application-Menu-400x123.jpg 400w" sizes="(max-width: 634px) 100vw, 634px" /></a></p>
<p>Now let&#8217;s run our application and see the output.</p>
<p><a href="https://sibeeshpassion.com/wp-content/uploads/2018/05/Result-From-NetCore2.0.jpg"><img decoding="async" class="alignnone size-full wp-image-12872" src="https://sibeeshpassion.com/wp-content/uploads/2018/05/Result-From-NetCore2.0.jpg" alt="" width="505" height="100" srcset="/wp-content/uploads/2018/05/Result-From-NetCore2.0.jpg 505w, /wp-content/uploads/2018/05/Result-From-NetCore2.0-300x59.jpg 300w, /wp-content/uploads/2018/05/Result-From-NetCore2.0-400x79.jpg 400w" sizes="(max-width: 505px) 100vw, 505px" /></a></p>
<h3>Update Visual Studio 2017 to the latest</h3>
<p>As a first step, to work with Dot net core 2.1 you need to update your IDE. There are a couple of ways you can update your IDE, but the easiest way is to go check the Notifications panel. Let&#8217;s see how to do that.</p>
<p>Go to the View tab and click on Notifications</p>
<p><a href="https://sibeeshpassion.com/wp-content/uploads/2018/05/Notification-Menu.jpg"><img decoding="async" class="alignnone size-full wp-image-12873" src="https://sibeeshpassion.com/wp-content/uploads/2018/05/Notification-Menu.jpg" alt="" width="406" height="433" srcset="/wp-content/uploads/2018/05/Notification-Menu.jpg 335w, /wp-content/uploads/2018/05/Notification-Menu-281x300.jpg 281w, /wp-content/uploads/2018/05/Notification-Menu-400x427.jpg 400w" sizes="(max-width: 406px) 100vw, 406px" /></a></p>
<p>Now you can see all the notifications here as shown in the below image. I always update my Visual Studio whenever there is an update, so you won&#8217;t be able to see that notification here on my panel. If you haven&#8217;t updated, and if you check the Notifications panel, I am sure you will get a link to the update here. You will be able to do further.</p>
<p><a href="https://sibeeshpassion.com/wp-content/uploads/2018/05/Notification-Panel.jpg"><img decoding="async" class="alignnone size-full wp-image-12874" src="https://sibeeshpassion.com/wp-content/uploads/2018/05/Notification-Panel.jpg" alt="" width="373" height="440" srcset="/wp-content/uploads/2018/05/Notification-Panel.jpg 303w, /wp-content/uploads/2018/05/Notification-Panel-254x300.jpg 254w" sizes="(max-width: 373px) 100vw, 373px" /></a></p>
<p>Once you have updated, you can verify your version.</p>
<p><a href="https://sibeeshpassion.com/wp-content/uploads/2018/05/Visual-Studio-15.7.2-1.jpg"><img decoding="async" class="alignnone wp-image-12876" src="https://sibeeshpassion.com/wp-content/uploads/2018/05/Visual-Studio-15.7.2-1.jpg" alt="" width="634" height="381" srcset="/wp-content/uploads/2018/05/Visual-Studio-15.7.2-1.jpg 594w, /wp-content/uploads/2018/05/Visual-Studio-15.7.2-1-300x180.jpg 300w, /wp-content/uploads/2018/05/Visual-Studio-15.7.2-1-768x462.jpg 768w, /wp-content/uploads/2018/05/Visual-Studio-15.7.2-1-400x241.jpg 400w" sizes="(max-width: 634px) 100vw, 634px" /></a></p>
<h3>Install latest Dot Net Core</h3>
<p>Here I am going to download the latest version from <a href="https://www.microsoft.com/net/download/dotnet-core/sdk-2.1.300-preview1">here</a>, however, you can select which version you want from <a href="https://www.microsoft.com/net/download">here</a>.</p>
<p><a href="https://sibeeshpassion.com/wp-content/uploads/2018/05/Dot-Net-Core-2.1-With-Run-Time.jpg"><img decoding="async" class="alignnone wp-image-12879" src="https://sibeeshpassion.com/wp-content/uploads/2018/05/Dot-Net-Core-2.1-With-Run-Time.jpg" alt="" width="634" height="470" srcset="/wp-content/uploads/2018/05/Dot-Net-Core-2.1-With-Run-Time.jpg 482w, /wp-content/uploads/2018/05/Dot-Net-Core-2.1-With-Run-Time-300x222.jpg 300w, /wp-content/uploads/2018/05/Dot-Net-Core-2.1-With-Run-Time-768x569.jpg 768w, /wp-content/uploads/2018/05/Dot-Net-Core-2.1-With-Run-Time-400x296.jpg 400w, /wp-content/uploads/2018/05/Dot-Net-Core-2.1-With-Run-Time-810x600.jpg 810w" sizes="(max-width: 634px) 100vw, 634px" /></a></p>
<p>As you can see that we have installed Dot Net Core SDK, Dot Net Core Runtime, Asp Net Core Runtime, and now you can see that the new version is available for you in Visual Studio 2017.</p>
<p><a href="https://sibeeshpassion.com/wp-content/uploads/2018/05/Select-Dot-Net-Core-2.1.jpg"><img decoding="async" class="alignnone size-full wp-image-12880" src="https://sibeeshpassion.com/wp-content/uploads/2018/05/Select-Dot-Net-Core-2.1.jpg" alt="" width="523" height="290" srcset="/wp-content/uploads/2018/05/Select-Dot-Net-Core-2.1.jpg 523w, /wp-content/uploads/2018/05/Select-Dot-Net-Core-2.1-300x166.jpg 300w, /wp-content/uploads/2018/05/Select-Dot-Net-Core-2.1-400x222.jpg 400w" sizes="(max-width: 523px) 100vw, 523px" /></a></p>
<h3>Changing the Target frameworks</h3>
<p>As the first step, we need to change the Target framework for our application. Here you can select it in the Properties or you can edit the dot(.)csproj file.</p>
<p>Now it is time to change the Microsoft.AspNetCore.All to Microsoft.AspNetCore.App, as with this version Microsoft have reduced the number of dependencies. We always need to install only the needed things right, instead of everything.</p>
<p><a href="https://sibeeshpassion.com/wp-content/uploads/2018/05/Microsoft-NetCore-All-to-NetCore-App.jpg"><img decoding="async" class="alignnone wp-image-12881 size-full" src="https://sibeeshpassion.com/wp-content/uploads/2018/05/Microsoft-NetCore-All-to-NetCore-App-e1527325484490.jpg" alt="" width="634" height="230" /></a></p>
<p>You will always need to change all of your references to the new version. Here I just wanted to show how you can do that. So, look into the packages you have in your application and change it accordingly.</p>
<h2>What is new in Dot(.) Net Core 2.1.x</h2>
<p>The Dot Net Core 2.1.x is a release with some cool new features, I strongly recommend you to read those <a href="https://blogs.msdn.microsoft.com/dotnet/2018/05/07/announcing-net-core-2-1-rc-1/">here.</a></p>
<p>I may write a new post with this features soon.</p>
<h2><span id="conclusion">Conclusion</span></h2>
<p>Thanks a lot for reading. Did I miss anything that you may think which is needed? Could you find this post as useful? I hope you liked this article. Please share me your valuable suggestions and feedback.</p>
<h2><span id="your-turn-what-do-you-think">Your turn. What do you think?</span></h2>
<p>A blog isn’t a blog without comments, but do try to stay on topic. If you have a question unrelated to this post, you’re better off posting it on C# Corner, Code Project, Stack Overflow, Asp.Net Forum instead of commenting here. Tweet or email me a link to your question there and I’ll definitely try to help if I can.</p>
<p>Kindest Regards<br />
Sibeesh Venu</p>
<p>&nbsp;</p>
<p>&nbsp;</p>
]]></content:encoded>
					
					<wfw:commentRss>https://mail.sibeeshpassion.com/how-to-update-net-core-2-0-application-to-2-1-version/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
		<item>
		<title>Creating a Chat Application in Node JS with Express, MongoDB, Mongoose and Socket.io</title>
		<link>https://mail.sibeeshpassion.com/creating-a-chat-application-in-node-js-with-express-mongodb-mongoose-and-socket-io/</link>
					<comments>https://mail.sibeeshpassion.com/creating-a-chat-application-in-node-js-with-express-mongodb-mongoose-and-socket-io/#disqus_thread</comments>
		
		<dc:creator><![CDATA[SibeeshVenu]]></dc:creator>
		<pubDate>Mon, 04 Dec 2017 12:09:50 +0000</pubDate>
				<category><![CDATA[CodeProject]]></category>
		<category><![CDATA[MongoDB]]></category>
		<category><![CDATA[Node JS]]></category>
		<category><![CDATA[Chat Application in Node JS]]></category>
		<category><![CDATA[Chat Application using Socket.io]]></category>
		<category><![CDATA[Mongoose]]></category>
		<category><![CDATA[Simple client side chat application]]></category>
		<category><![CDATA[Socket.io]]></category>
		<guid isPermaLink="false">https://sibeeshpassion.com/?p=12595</guid>

					<description><![CDATA[[toc] Introduction In this article, we are going to a chat application in Node JS  with the back end MongoDB.  We will also be using Mongoose for creating the MongoDB models and Socket.io for making multi directional chats on multiple client window. If you are really new to the Node JS, I strongly recommend you to read some articles on the same here. You can also see how you can create a sample Node application with MongoDB and Mongoose here. At the end of this article, I guarantee that you will be having some basic knowledge on the mentioned technologies. I hope you will [&#8230;]]]></description>
										<content:encoded><![CDATA[<p>[toc]</p>
<h3>Introduction</h3>
<p>In this article, we are going to a chat application in <a href="http://sibeeshpassion.com/category/Node-JS/">Node JS</a>  with the back end <a href="http://sibeeshpassion.com/category/MongoDB">MongoDB.</a>  We will also be using <a href="http://sibeeshpassion.com/tag/Mongoose/">Mongoose</a> for creating the MongoDB models and <a href="http://sibeeshpassion.com/tag/Socket.io/">Socket.io</a> for making multi directional chats on multiple client window. If you are really new to the Node JS, I strongly recommend you to read some articles on the same <a href="http://sibeeshpassion.com/category/Node-JS/">here</a>. You can also see how you can create a sample Node application with MongoDB and Mongoose <a href="http://sibeeshpassion.com/using-mongodb-on-node-js-application-using-mongoose/">here</a>. At the end of this article, I guarantee that you will be having some basic knowledge on the mentioned technologies. I hope you will like this article.</p>
<h3><span id="source-code">Source Code</span></h3>
<p>You can always clone or download the source code <a href="https://code.msdn.microsoft.com/ChatApp-NodeJS-Socketio-22325371">here</a></p>
<h3>Background</h3>
<p>Creating a chat application is always an interesting this to do. And it is a good way to learn a lot, because you are creating some interactions on your application. And with the release of few technologies we can create such application without any hassle. It is much more easier than ever. Here we are also going to create a chat application. A basic knowledge of Node JS, MongoDB, JavaScript, JQuery is more than enough to create this project. So, please be with me. Let&#8217;s just skip the talking and start developing.</p>
<h3>Setting up Node application</h3>
<p>This step requires some basic knowledge, please see some of that <a href="http://sibeeshpassion.com/using-mongodb-on-node-js-application-using-mongoose/">here</a>.  So as mentioned in that article, we have successfully created our Package.json file and installed the required packages. Let&#8217;s review our package.json file.</p>
<pre class="EnlighterJSRAW" data-enlighter-language="json">{
 "name": "chatapp",
 "version": "1.0.0",
 "description": "A chat application in Node JS, which uses MongoDB, Mongoose and Socket.io",
 "main": "index.js",
 "scripts": {
 "test": "echo \"Error: no test specified\" &amp;&amp; exit 1"
 },
 "keywords": [
 "Node",
 "JS",
 "MongoDB",
 "Mongoose",
 "Socket.io"
 ],
 "author": "Sibeesh Venu",
 "license": "ISC",
 "dependencies": {
 }
}
</pre>
<p>Let&#8217;s install the packages now by running the below commands.</p>
<pre class="EnlighterJSRAW" data-enlighter-language="shell">npm install --save express
npm install --save mongoose
npm install --save body-parser
npm install --save socket.io</pre>
<p>Now that we have all the dependencies added to the package.json file.</p>
<pre class="EnlighterJSRAW" data-enlighter-language="json">"dependencies": {
    "body-parser": "^1.18.2",
    "express": "^4.16.2",
    "mongoose": "^4.13.6",
    "socket.io": "^2.0.4"
  }</pre>
<h4>Creating an App using Express</h4>
<p>Let&#8217;s create a file server.js and build an app using Express.</p>
<pre class="EnlighterJSRAW" data-enlighter-language="js">var express = require("express")
var app = express()
app.listen(3020,()=&gt;{
 console.log("Well done, now I am listening...")
})</pre>
<p>I hope you are getting  the desired output, if not, please don&#8217;t worry, just double check the codes you had written.</p>
<h4>Running our application on browser</h4>
<p>Let&#8217;s run our application on port 3020 and see what we are getting <a href="http://localhost:3020/">http://localhost:3020/</a>..</p>
<p>Yes you will get an error as <code class="EnlighterJSRAW" data-enlighter-language="js">Cannot GET /</code>  , no worries. To fix that you need to add the following code block to your server.js file</p>
<pre class="EnlighterJSRAW" data-enlighter-language="js">app.use(express.static(__dirname))</pre>
<h4>Creating Index page</h4>
<p>Here I am going to create a <a href="http://sibeeshpassion.com/category/HTML5/">HTML 5</a> page with <a href="http://sibeeshpassion.com/category/JQuery/">JQuery</a> and Bootstrap referenced in it.</p>
<pre class="EnlighterJSRAW" data-enlighter-language="html">&lt;!DOCTYPE html&gt;
&lt;title&gt;Creating a Chat Application in Node JS with Express, MongoDB, Mongoose and Socket.io&lt;/title&gt;
&lt;link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0-beta.2/css/bootstrap.min.css" crossorigin="anonymous"&gt;
&lt;script src="https://code.jquery.com/jquery-3.2.1.min.js" crossorigin="anonymous"&gt;&lt;/script&gt;
&lt;script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.12.3/umd/popper.min.js" crossorigin="anonymous"&gt;&lt;/script&gt;
&lt;script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0-beta.2/js/bootstrap.min.js" crossorigin="anonymous"&gt;&lt;/script&gt;

&lt;div class="container"&gt;
    &lt;br&gt;
    &lt;div class="jumbotron"&gt;
        &lt;h1 class="dispaly-4"&gt;Start Chatting&lt;/h1&gt;
        &lt;br&gt;
        &lt;input id="txtName" class="form-control" placeholder="Name" type="text"&gt;
        &lt;br&gt;
        &lt;textarea id="txtMessage" class="form-control" placeholder="Message"&gt;&lt;/textarea&gt;
        &lt;br&gt;
        &lt;button id="send" class="btn btn-success"&gt;Send&lt;/button&gt;
    &lt;/div&gt;
    &lt;div id="messages"&gt;&lt;/div&gt;
&lt;/div&gt;
</pre>
<p>As you can see, the page has two text boxes and one button. We will be creating some scripts very soon which uses these controls.</p>
<h3>Start developing the chat app</h3>
<p>Till now, it was all basic, and we have done it well. Now it is time to go and write some advanced codes. So, are you ready?</p>
<h4>Create model from page data</h4>
<p>Here we are going to create the model from the page data, that is, from the controls we have in our page. We will be using JQuery to do so.</p>
<pre class="EnlighterJSRAW" data-enlighter-language="js">&lt;script&gt;
    $(() =&gt; {
        $("send").click(() =&gt; {
            var chatMessage = {
                name: $("#txtName").val(), chat: $("#txtMessage").val()
            }
            postChat(chat)
        })
    })

    function postChat(chat){
        console.log(chat)
    }

&lt;/script&gt;</pre>
<p>Now that we have got the model from the user, let&#8217;s save it to the DB.</p>
<div id="attachment_12596" style="width: 428px" class="wp-caption alignnone"><a href="http://sibeeshpassion.com/wp-content/uploads/2017/12/Model-values-on-browser-console.png"><img decoding="async" aria-describedby="caption-attachment-12596" class="size-full wp-image-12596" src="http://sibeeshpassion.com/wp-content/uploads/2017/12/Model-values-on-browser-console.png" alt="Model values on browser console" width="418" height="446" srcset="/wp-content/uploads/2017/12/Model-values-on-browser-console.png 418w, /wp-content/uploads/2017/12/Model-values-on-browser-console-281x300.png 281w, /wp-content/uploads/2017/12/Model-values-on-browser-console-400x427.png 400w" sizes="(max-width: 418px) 100vw, 418px" /></a><p id="caption-attachment-12596" class="wp-caption-text">Model values on browser console</p></div>
<h4>Setting up database</h4>
<p>We are going to set up our database in mLab as mentioned in this article <a href="http://sibeeshpassion.com/using-mongodb-on-node-js-application-using-mongoose/">Using MongoDB on Node JS Application Using Mongoose.</a> So let&#8217;s just require Mongoose and do the needed changes.</p>
<pre class="EnlighterJSRAW" data-enlighter-language="js">var express = require("express")
var mongoose = require("mongoose")

var app = express()

var conString = "mongodb://admin:admin@ds038319.mlab.com:38319/mylearning"
app.use(express.static(__dirname))

var Chats = mongoose.model("Chats", {
    name: String,
    chat: String
})

mongoose.connect(conString, { useMongoClient: true }, (err) =&gt; {
    console.log("Database connection", err)
})

app.listen(3020, () =&gt; {
    console.log("Well done, now I am listening...")
})</pre>
<h4>Creating a Post request</h4>
<p>Now let&#8217;s create a post requests in our index.html file which will the post API in our server.js file.</p>
<p><em><span style="text-decoration: underline;">index.html</span></em></p>
<pre class="EnlighterJSRAW" data-enlighter-language="js">function postChat(chat) {
        $.post("http://localhost:3020/chats", chat)
}</pre>
<p><span style="text-decoration: underline;"><em>server.js</em></span></p>
<pre class="EnlighterJSRAW" data-enlighter-language="js">app.post("/chats", async (req, res) =&gt; {
    try {
        var chat = new Chats(req.body)
        await chat.save()
        res.sendStatus(200)
    } catch (error) {
        res.sendStatus(500)
        console.error(error)
    }
})
</pre>
<p>Let&#8217;s just run our application and test it out.</p>
<p>You may be getting an error as &#8220;(node:10824) DeprecationWarning: Mongoose: mpromise (mongoose&#8217;s default promise library) is deprecated, plug in your own promise library instead: http://mongoosejs.com/docs/promises.html&#8221;&#8221;, here to fix this, we need to use the default promise instead of the Mongoose promise. Let&#8217;s change that. Add this code <code class="EnlighterJSRAW" data-enlighter-language="js">mongoose.Promise = Promise</code> to our server.js file. Give it a try after setting it.</p>
<p>Still it is not working right, you are getting <em>undefined </em>at the place, <code class="EnlighterJSRAW" data-enlighter-language="js">var chat = new Chats(req.body)</code> in our Post API . At this stage, we will have to use our body-parser packages, do you remember the package we have installed? Let&#8217;s just require that package <code class="EnlighterJSRAW" data-enlighter-language="js">var bodyParser = require("body-parser")</code> add the preceding codes to our server.js file.</p>
<pre class="EnlighterJSRAW" data-enlighter-language="js">app.use(bodyParser.json());
app.use(bodyParser.urlencoded({ extended: false }))</pre>
<p>Now this will convert the request to a JSON object by default. Give it a try again, I am sure you will get the actual value instead of undefined.</p>
<h4>Creating a Get request for all the chat data</h4>
<p>We have written codes to write our data into our database, we will have to show this data on our page right? Here we are going to write the get requests in out index.html page which will call the get API.</p>
<p><em><span style="text-decoration: underline;">index.html</span></em></p>
<pre class="EnlighterJSRAW" data-enlighter-language="null">function getChats() {
     $.get("/chats", (chats) =&gt; {
         chats.forEach(addChat)
     })
}

function addChat(chatObj){
    $("#messages").append(`&lt;h5&gt;${chatObj.name} &lt;/h5&gt;&lt;p&gt;${chatObj.chat}&lt;/p&gt;`);
}</pre>
<p>And call the function getChats() in document ready event.</p>
<p><em><span style="text-decoration: underline;">server.js</span></em></p>
<pre class="EnlighterJSRAW" data-enlighter-language="js">app.get("/chats", (req, res) =&gt; {
    Chats.find({}, (error, chats) =&gt; {
        res.send(chats)
    })
})</pre>
<p>Here we are passing {} to our find function, this means, we are going to get all the chats without any filter. Just run your application now, and check whether you are getting the chat messages you had sent.</p>
<div id="attachment_12597" style="width: 369px" class="wp-caption alignnone"><a href="http://sibeeshpassion.com/wp-content/uploads/2017/12/Retreiving-data-from-a-MongoDB.png"><img decoding="async" aria-describedby="caption-attachment-12597" class="size-full wp-image-12597" src="http://sibeeshpassion.com/wp-content/uploads/2017/12/Retreiving-data-from-a-MongoDB.png" alt="Retrieving data from a MongoDB" width="359" height="514" srcset="/wp-content/uploads/2017/12/Retreiving-data-from-a-MongoDB.png 359w, /wp-content/uploads/2017/12/Retreiving-data-from-a-MongoDB-210x300.png 210w" sizes="(max-width: 359px) 100vw, 359px" /></a><p id="caption-attachment-12597" class="wp-caption-text">Retrieving data from a MongoDB</p></div>
<h3>Implementing Socket.io</h3>
<p>Now the chat we are sending is getting saved to our database and we are able to load the same on page load. Is it the behavior of a perfect chat application? Absolutely no, a perfect chat application will be able to,</p>
<ol>
<li>Show the chat message to the UI right after the data gets inserted to database</li>
<li>Show the chats in multiple clients, here in our application, if you are opening the URL in multiple browser instance, and if you need to show the chats to both instances, you will have to refresh the pages right? This is not a recommended way</li>
</ol>
<p>That&#8217;s why we are going to implement Socket.io in our application.</p>
<h4>Require the package</h4>
<p>Unlike the other packages, adding socket.io to the application is a different process, we will have to require the http server first, then, set our app. You can see more information on socket.io <a href="https://socket.io/">here</a>.</p>
<pre class="EnlighterJSRAW" data-enlighter-language="js">var http = require("http").Server(app)
var io= require("socket.io")(http)</pre>
<h4>Enabling the connection</h4>
<p>To enable the connection, we need to use the function io.on.</p>
<pre class="EnlighterJSRAW" data-enlighter-language="js">io.on("connection", (socket) =&gt; {
    console.log("Socket is connected...")
})</pre>
<h4>Listen using new http server</h4>
<p>Now that we have a new http server, and we should change our listen code to our new http.</p>
<pre class="EnlighterJSRAW" data-enlighter-language="js">var server = http.listen(3020, () =&gt; {
    console.log("Well done, now I am listening on ", server.address().port)
})</pre>
<h4>Changes in script</h4>
<p>Let&#8217;s do listen for the event &#8220;chat&#8221; now in our html page.</p>
<pre class="EnlighterJSRAW" data-enlighter-language="js">var socket = io()
socket.on("chat", addChat)</pre>
<p>Please do not forget to include the socket.io.js reference in our index page, other wise you may get an error as &#8220;Uncaught ReferenceError: io is not defined&#8221;</p>
<h4>Emits the event</h4>
<p>Once the above step is completed we need to make sure we are emitting the new event on our Post API.</p>
<pre class="EnlighterJSRAW" data-enlighter-language="js">app.post("/chats", async (req, res) =&gt; {
 try {
 var chat = new Chats(req.body)
 await chat.save()
 res.sendStatus(200)

 //Emit the event
 io.emit("chat", req.body)

 } catch (error) {
 res.sendStatus(500)
 console.error(error)
 }
})</pre>
<p>&nbsp;</p>
<p>Let&#8217;s just run our application in two browser instances and check for the output.</p>
<div id="attachment_12598" style="width: 644px" class="wp-caption alignnone"><a href="http://sibeeshpassion.com/wp-content/uploads/2017/12/Socket.io-Output-e1512388473997.png"><img decoding="async" aria-describedby="caption-attachment-12598" class="size-full wp-image-12598" src="http://sibeeshpassion.com/wp-content/uploads/2017/12/Socket.io-Output-e1512388473997.png" alt="Socket.io Output" width="634" height="596" /></a><p id="caption-attachment-12598" class="wp-caption-text">Socket.io Output</p></div>
<p>Please make sure that you are getting the chats in the second instance when you send it from the first instance of the browser and vice versa.</p>
<p>&nbsp;</p>
<h3><span id="conclusion">Conclusion</span></h3>
<p>Thanks a lot for reading. Did I miss anything that you may think which is needed? Could you find this post as useful? I hope you liked this article. Please share me your valuable suggestions and feedback.</p>
<h3><span id="your-turn-what-do-you-think">Your turn. What do you think?</span></h3>
<p>A blog isn’t a blog without comments, but do try to stay on topic. If you have a question unrelated to this post, you’re better off posting it on C# Corner, Code Project, Stack Overflow, Asp.Net Forum instead of commenting here. Tweet or email me a link to your question there and I’ll definitely try to help if I can.</p>
<p>Kindest Regards<br />
Sibeesh Venu</p>
]]></content:encoded>
					
					<wfw:commentRss>https://mail.sibeeshpassion.com/creating-a-chat-application-in-node-js-with-express-mongodb-mongoose-and-socket-io/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
		<item>
		<title>Create a Microsoft Azure Cognitive Service FaceAPI Application in Half an Hour</title>
		<link>https://mail.sibeeshpassion.com/create-a-microsoft-azure-cognitive-service-faceapi-application-in-half-an-hour/</link>
					<comments>https://mail.sibeeshpassion.com/create-a-microsoft-azure-cognitive-service-faceapi-application-in-half-an-hour/#disqus_thread</comments>
		
		<dc:creator><![CDATA[SibeeshVenu]]></dc:creator>
		<pubDate>Wed, 12 Jul 2017 00:00:04 +0000</pubDate>
				<category><![CDATA[Azure]]></category>
		<category><![CDATA[CodeProject]]></category>
		<category><![CDATA[Cognitive Service]]></category>
		<category><![CDATA[Face Comparison Using FaceAPI]]></category>
		<category><![CDATA[Face Identify]]></category>
		<category><![CDATA[FaceAPI]]></category>
		<category><![CDATA[Microsoft]]></category>
		<guid isPermaLink="false">http://sibeecst_passion.com/?p=12471</guid>

					<description><![CDATA[[toc] Introduction In this article, we are going to create Microsoft Azure Cognitive Service Face API in half an hour. Microsoft Azure Cognitive Services are set of APIs and Services available for the developers to make their applications more interactive and intelligent. This was formerly known as Project Oxford. Here Microsoft uses Machine Learning in the background to create these APIs. So far we have the preceding list of APIs. Emotion and video detection Facial Recognition Speech Recognition Vision Recognition Speech and language understanding Prerequisites Azure Subscription Visual Studio If you don&#8217;t have any Azure subscription, please sign up for [&#8230;]]]></description>
										<content:encoded><![CDATA[
<p>[toc]</p>



<h3 class="wp-block-heading">Introduction</h3>



<p>In this article, we are going to create Microsoft Azure Cognitive Service Face API in half an hour. Microsoft Azure Cognitive Services are set of APIs and Services available for the developers to make their applications more interactive and intelligent. This was formerly known as Project Oxford. Here Microsoft uses Machine Learning in the background to create these APIs. So far we have the preceding list of APIs.</p>



<ul class="wp-block-list"><li>Emotion and video detection</li><li>Facial Recognition</li><li>Speech Recognition</li><li>Vision Recognition</li><li>Speech and language understanding</li></ul>



<h3 class="wp-block-heading">Prerequisites</h3>



<ul class="wp-block-list"><li>Azure Subscription</li><li>Visual Studio</li></ul>



<blockquote class="wp-block-quote is-layout-flow wp-block-quote-is-layout-flow"><p>If you don&#8217;t have any Azure subscription, please sign up for a subscription <a href="https://azure.microsoft.com/en-in/pricing/member-offers/msdn-benefits-details/" target="_blank" rel="noopener noreferrer">here</a>.</p></blockquote>



<h3 class="wp-block-heading">Download the source code</h3>



<p>You can always download the source code used for this video from here</p>



<ul class="wp-block-list"><li><a href="https://code.msdn.microsoft.com/Create-a-Azure-Cognitive-291065b2" target="_blank" rel="noopener noreferrer">AzureCognitiveServicesFaceAPI</a></li></ul>



<h3 class="wp-block-heading">Create the Face API in <a href="http://sibeeshpassion.com/category/azure/" target="_blank" rel="noopener noreferrer">Azure </a>portal</h3>



<p>To know how to create a Face Recognition API in Azure portal, please see the video preceding.</p>



<p><iframe loading="lazy" width="1200" height="675" src="https://www.youtube.com/embed/qYi91SC19iE?feature=oembed" frameborder="0" allow="autoplay; encrypted-media" allowfullscreen></iframe></p>



<h3 class="wp-block-heading">Add reference of Microsoft.ProjectOxford.Face to your project</h3>



<p>Before we start coding, please make sure that you add the reference of <em>Microsoft.ProjectOxford.Face</em> from NuGet package manager.</p>



<figure class="wp-block-image alignnone"><a href="http://sibeeshpassion.com/wp-content/uploads/2017/07/Microsoft.ProjectOxford.Face_-e1499879129697.png"><img decoding="async" src="http://sibeeshpassion.com/wp-content/uploads/2017/07/Microsoft.ProjectOxford.Face_-e1499879129697.png" alt="Microsoft.ProjectOxford.Face" class="wp-image-12484"/></a><figcaption>Microsoft.ProjectOxford.Face</figcaption></figure>



<h3 class="wp-block-heading">Using the code</h3>



<p>To get started, open your <a href="http://sibeeshpassion.com/category/tools/visual-studio/" target="_blank" rel="noopener noreferrer">Visual Studio</a> and create a new WPF application.</p>



<h4 class="wp-block-heading">Add Image and button control to MainWindow.xaml</h4>



<p>&lt;button>&lt;/button></p>



<h4 class="wp-block-heading">Create an instance of IFaceServiceClient</h4>



<script src="https://gist.github.com/SibeeshVenu/63fb2a6f593173fc5cef6a1b3a879c98.js"></script>



<blockquote class="wp-block-quote is-layout-flow wp-block-quote-is-layout-flow"><p>If you are selecting the location as Southeast Asia while creating the Face API in portal, it is mandatory to use the second parameter, that is, your end point.</p></blockquote>



<h4 class="wp-block-heading">Load the image to image control</h4>



<script src="https://gist.github.com/SibeeshVenu/2129b1dbc7c2dd1ed2ea0a30e412f81c.js"></script>



<h4 class="wp-block-heading">Detect the faces count</h4>



<script src="https://gist.github.com/SibeeshVenu/7b5eab9e1894b163ff096548a5cb4b23.js"></script>



<h4 class="wp-block-heading">Draw the rectangles in faces found</h4>



<script src="https://gist.github.com/SibeeshVenu/ed0d2bd327f7ac7cee29f57447d08d29.js"></script>



<h3 class="wp-block-heading">Output</h3>



<p>Now run your application and upload an image, it can be a single picture or a group picture.</p>



<figure class="wp-block-image alignnone"><a href="http://sibeeshpassion.com/wp-content/uploads/2017/07/Azure-Face-Recognition-API-Output-e1499878818343.png"><img decoding="async" src="http://sibeeshpassion.com/wp-content/uploads/2017/07/Azure-Face-Recognition-API-Output-e1499878818343.png" alt="Azure Face Recognition API Output" class="wp-image-12483"/></a><figcaption>Azure Face Recognition API Output</figcaption></figure>



<h3 class="wp-block-heading">Check the statistics in Azure portal</h3>



<p>If everything goes fine, you will be able to see the statistics in your Azure portal as preceding.</p>



<figure class="wp-block-image alignnone"><a href="http://sibeeshpassion.com/wp-content/uploads/2017/07/Face-API-Metric-In-Azure-Portal-e1499878282399.png"><img decoding="async" src="http://sibeeshpassion.com/wp-content/uploads/2017/07/Face-API-Metric-In-Azure-Portal-e1499878282399.png" alt="Face API Metric In Azure Portal" class="wp-image-12482"/></a><figcaption>Face API Metric In Azure Portal</figcaption></figure>



<h3 class="wp-block-heading">To Do</h3>



<p>If you would like to compare the images or identify the person in an image, please read the documentation here <a href="https://docs.microsoft.com/en-us/azure/cognitive-services/face/face-api-how-to-topics/howtoidentifyfacesinimage" target="_blank" rel="noopener noreferrer">Face identifying and comparing with Azure Face API</a></p>



<h3 class="wp-block-heading">Conclusion</h3>



<p>Did I miss anything that you may think which is needed? Could you find this post as useful? I hope you liked this article. Please share me your valuable suggestions and feedback.</p>



<h3 class="wp-block-heading">Your turn. What do you think?</h3>



<p>A blog isn’t a blog without comments, but do try to stay on topic. If you have a question unrelated to this post, you’re better off posting it on C# Corner, Code Project, Stack Overflow, Asp.Net Forum instead of commenting here. Tweet or email me a link to your question there and I’ll definitely try to help if I can.</p>



<p>Kindest Regards<br>Sibeesh Venu</p>
]]></content:encoded>
					
					<wfw:commentRss>https://mail.sibeeshpassion.com/create-a-microsoft-azure-cognitive-service-faceapi-application-in-half-an-hour/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
		<item>
		<title>Do you know JavaScript? Are you sure? &#8211; Part 1</title>
		<link>https://mail.sibeeshpassion.com/do-you-know-javascript-are-you-sure-part-1/</link>
					<comments>https://mail.sibeeshpassion.com/do-you-know-javascript-are-you-sure-part-1/#disqus_thread</comments>
		
		<dc:creator><![CDATA[SibeeshVenu]]></dc:creator>
		<pubDate>Tue, 28 Feb 2017 17:22:18 +0000</pubDate>
				<category><![CDATA[CodeProject]]></category>
		<category><![CDATA[How to]]></category>
		<category><![CDATA[JavaScript]]></category>
		<category><![CDATA[Javascript]]></category>
		<category><![CDATA[JavaScript Basics]]></category>
		<category><![CDATA[JavaScript In Simple Language]]></category>
		<category><![CDATA[JavaScript Objects]]></category>
		<category><![CDATA[JavaScript Simple Demo]]></category>
		<category><![CDATA[JavaScript Tutorial]]></category>
		<guid isPermaLink="false">http://sibeecst_passion.com/?p=12064</guid>

					<description><![CDATA[[toc] Introduction Here we are going to a series of articles related to JavaScript. As this is the first part of the series, here we are going to see some basics of JavaScript which you may forgot or you may not be aware of it. You can always see my other posts related to JavaScript here. We will be using Visual Studio for our development. Basically, JavaScript is a programming language of HTML and Web. Now a days we can create any kind of applications using JavaScript. If you are totally new to JavaScript, I strongly recommend you to read [&#8230;]]]></description>
										<content:encoded><![CDATA[<p>[toc]</p>
<h3>Introduction</h3>
<p>Here we are going to a series of articles related to <a href="http://sibeeshpassion.com/category/JavaScript" target="_blank" rel="noopener">JavaScript</a>. As this is the first part of the series, here we are going to see some basics of JavaScript which you may forgot or you may not be aware of it. You can always see my other posts related to JavaScript <a href="http://sibeeshpassion.com/category/JavaScript/" target="_blank" rel="noopener">here</a>. We will be using <a href="http://sibeeshpassion.com/category/Visual-Studio/" target="_blank" rel="noopener">Visual Studio</a> for our development. Basically, JavaScript is a programming language of <a href="http://sibeeshpassion.com/category/html5/" target="_blank" rel="noopener">HTML</a> and Web. Now a days we can create any kind of applications using JavaScript. If you are totally new to JavaScript, I strongly recommend you to read some basics <a href="https://www.w3schools.com/js/" target="_blank" rel="noopener">here</a>. I hope you will like this. Now let&#8217;s begin.</p>
<h3><strong>Download source code</strong></h3>
<p>You can always download the source code from here <a href="https://code.msdn.microsoft.com/Do-you-know-JavaScript-ff7f3f98" target="_blank" rel="noopener">Do you know JavaScript &#8211; Part 1</a></p>
<h3><strong>Background</strong></h3>
<p>Recently I was assigned to a training task where I need to train one of my colleague who is a fresher and totally new to programming field. I had covered almost all the topics in my training and I am sharing few of them here. I hope you will like this.</p>
<h3>Using the code</h3>
<h4><strong>Create a HTML page</strong></h4>
<p>As we already said, JavaScript is a programming language of HTML and Web, we need a page to work with JavaScript. Let&#8217;s create it first.</p>
<p>[html]<br />
&lt;!DOCTYPE html&gt;<br />
&lt;html&gt;<br />
&lt;head&gt;<br />
&lt;title&gt;&lt;/title&gt;<br />
&lt;meta charset=&#8221;utf-8&#8243; /&gt;<br />
&lt;/head&gt;<br />
&lt;body&gt;<br />
&lt;/body&gt;<br />
&lt;/html&gt;<br />
[/html]</p>
<p>Now create a JS file and include it in your page.</p>
<p>[js]<br />
&lt;script src=&#8221;JavaScript.js&#8221;&gt;&lt;/script&gt;<br />
[/js]</p>
<h4><strong>Let&#8217;s begin our tutorial</strong></h4>
<p>Any idea, what will be the output of the preceding lines of code.</p>
<p>[js]<br />
console.log(2 + 2);<br />
console.log(2 + &#8220;2&#8221;);<br />
console.log(2 + &#8220;2&#8221; + 2);<br />
console.log(2 + 2 + &#8220;2&#8221; + 2);<br />
console.log(2 + 2 + &#8220;2&#8221; + 2 + 2);<br />
console.log(2 + &#8220;2&#8221; + 2 + &#8220;2&#8221; + 2 + 2);<br />
console.log(&#8220;2&#8221; + 2 + &#8220;2&#8221; + 2 + 2 + 2 + 2);<br />
[/js]</p>
<p>Once after you run your application, press CTRL+SHIFT+J if you are opening your application in Google chrome or CTRL+SHIFT+K if it is Mozilla, or press F12 if in IE. This will open the browser console. Now check the output, is it the same as you thought?</p>
<p><div id="attachment_12065" style="width: 644px" class="wp-caption alignnone"><a href="http://sibeeshpassion.com/wp-content/uploads/2017/02/Javascript_tutorial_output_1-e1488299369883.png"><img decoding="async" aria-describedby="caption-attachment-12065" class="size-full wp-image-12065" src="http://sibeeshpassion.com/wp-content/uploads/2017/02/Javascript_tutorial_output_1-e1488299369883.png" alt="Javascript_tutorial_output_1" width="634" height="197" srcset="/wp-content/uploads/2017/02/Javascript_tutorial_output_1-e1488299369883.png 634w, /wp-content/uploads/2017/02/Javascript_tutorial_output_1-e1488299369883-300x93.png 300w, /wp-content/uploads/2017/02/Javascript_tutorial_output_1-e1488299369883-400x124.png 400w" sizes="(max-width: 634px) 100vw, 634px" /></a><p id="caption-attachment-12065" class="wp-caption-text">Javascript_tutorial_output_1</p></div></p>
<p>If you noticed well, <em>console.log(2 + 2 + &#8220;2&#8221; + 2 + 2);</em> returned <em>4222</em>. First twos are added and when it comes to the third digit, the type of the result is being changed to string, so the string concatenation is happening. This is because of the dynamica nature of JavaScript.</p>
<p>So you can always add different types of values to the same variable in JavaScript. The preceding codes will always be working perfect.</p>
<p>[js]<br />
var a = 1;<br />
a = &#8220;Sibeesh&#8221;;<br />
[/js]</p>
<p>Now a simple test, what will be the output of the preceding code?</p>
<p>[js]<br />
var b;<br />
console.log(b);<br />
[/js]</p>
<p>Yes you are right it will return undefined as we have not assigned any values to the variable b. Have you ever checked the typeof an undefined variable?</p>
<p>[js]<br />
console.log(typeof(b));<br />
[/js]</p>
<p>The result will be undefined. Now what about the preceding codes?</p>
<p>[js]<br />
console.log(typeof(undefined));<br />
console.log(typeof(typeof(b)));<br />
console.log(typeof(String(b)));<br />
console.log(typeof({a:b}));<br />
console.log(typeof(null));<br />
[/js]</p>
<p>It can give you an output as below.</p>
<p>[js]<br />
undefined<br />
string<br />
string<br />
object<br />
object<br />
[/js]</p>
<p>Here one thing to be noted is, <em>typeof(typeof())</em> will always return string. And <em>{a:b}, null</em> is actually objects so the typeof will return the type as object. Let&#8217;s write a simple program now.</p>
<p>[js]<br />
var a=1;<br />
var b=a;<br />
a=2;</p>
<p>console.log(b);<br />
console.log(a);<br />
[/js]</p>
<p>See, how simple it was. Any idea what would be the output of that? If your answer is 1 &amp; 2, then you are right? Have you ever thought why is that? This is why the variable we just created are primitive types. In primitive data types the values are saved directly on the variable. If you are coming from the backgound of C#, you can understand the value typed variable.</p>
<p>Now we have one more data type which is referenced variable where values are stored as a reference not a direct values. An example for a referenced type variable is Object. Let&#8217;s go on to the next topic which is overview on JavaScript Objects, Do you know how to create an object?</p>
<p>[js]<br />
var myName = {firstName: &#8220;Sibeesh&#8221;, lastName: &#8220;Venu&#8221;};<br />
console.log(myName);<br />
console.log(JSON.stringify(myName));<br />
console.log(myName.firstName);<br />
console.log(myName.lastName);<br />
[/js]</p>
<p>Here myName is an object. You can always use JSON.stringify() to make your object to a string format and JSON.parse() to make your string to object. So the above code will give you an output as follows.</p>
<p><div id="attachment_12066" style="width: 644px" class="wp-caption alignnone"><a href="http://sibeeshpassion.com/wp-content/uploads/2017/02/Javascript_tutorial_output_2-e1488300962889.png"><img decoding="async" aria-describedby="caption-attachment-12066" class="size-full wp-image-12066" src="http://sibeeshpassion.com/wp-content/uploads/2017/02/Javascript_tutorial_output_2-e1488300962889.png" alt="Javascript_tutorial_output_2" width="634" height="101" srcset="/wp-content/uploads/2017/02/Javascript_tutorial_output_2-e1488300962889.png 634w, /wp-content/uploads/2017/02/Javascript_tutorial_output_2-e1488300962889-300x48.png 300w, /wp-content/uploads/2017/02/Javascript_tutorial_output_2-e1488300962889-400x64.png 400w" sizes="(max-width: 634px) 100vw, 634px" /></a><p id="caption-attachment-12066" class="wp-caption-text">Javascript_tutorial_output_2</p></div></p>
<p>An object is a collection of key-value pairs, like we see in the above object, firstName is key and &#8220;Sibeesh&#8221; is value. How can we take any values from an object? We can always access a property from an object using dot(.) operator as follows.</p>
<p>[js]<br />
console.log(myName.firstName);<br />
console.log(myName.lastName);<br />
[/js]</p>
<p>And also using a bracket ([)</p>
<p>[js]<br />
console.log(myName[&#8220;firstName&#8221;]);<br />
console.log(myName[&#8220;lastName&#8221;]);<br />
[/js]</p>
<p>The above codes will give you an output as &#8220;Sibeesh&#8221; &#8220;Venu&#8221;, right? We just accesses a property from an object. Now we have given string value to our object as a key? Is there anyway we can give a key in number format? Let&#8217;s have a look.</p>
<p>[js]<br />
var myName = {1: &#8220;Sibeesh&#8221;, 2: &#8220;Venu&#8221;};<br />
[/js]</p>
<p>The question is, how can we access values of the keys 1 &amp; 2? Like below?</p>
<p>[js]<br />
console.log(myName.1);<br />
console.log(myName.2);<br />
[/js]</p>
<p>If you said &#8220;Yes&#8221;, you are wrong. If you try to accecc the values as above, This will throw an &#8220;Uncaught SyntaxError&#8221; error, so how can we access it?</p>
<p>[js]<br />
console.log(myName[&#8220;1&#8221;]);<br />
console.log(myName[&#8220;2&#8221;]);<br />
[/js]</p>
<p>So when the key value is a number, we must use [] for accessing the values. Now Lets go back to the previous object.</p>
<p>[js]<br />
var myName = {firstName: &#8220;Sibeesh&#8221;, lastName: &#8220;Venu&#8221;};<br />
var myNameCopy= myName;<br />
myName.firstName = &#8220;Sibi&#8221;;</p>
<p>console.log(myName.firstName);<br />
console.log(myNameCopy.firstName);<br />
[/js]</p>
<p>Any idea what will be the output of the above code? Have you just said Sibi Sibeesh? Oh, man. You got confused. The actual output is Sibi Sibi. As we said earlier, an object is an example of referenced type variable where the values are stored as a reference to it. So even if change the value of our first object, that will reflect is our second one too.</p>
<p>In the above examples we have created objects like below</p>
<p>[js]<br />
var myName = {firstName: &#8220;Sibeesh&#8221;, lastName: &#8220;Venu&#8221;};<br />
[/js]</p>
<p>This way of careating an object is called <em>Object literals</em>. Now the questuion is, is this the only way of creating the object? There is one more way, which is known as <em>Object Constructor</em>. Now we can create the same objects in Object constructor way.</p>
<p>[js]<br />
var myName = new Object();<br />
myName.firstName = &#8220;Sibeesh&#8221;<br />
myName.lastName = &#8220;Venu&#8221;;<br />
console.log(myName.firstName);<br />
console.log(myName.lastName);<br />
[/js]</p>
<p>Is there any rule that we can add only varibles to an object? Absolutely no, an object can hold a function too. Let&#8217;s create an object with a function inside.</p>
<p>[js]<br />
var myName = {<br />
firstName: &#8220;Sibeesh&#8221;,<br />
lastName: &#8220;Venu&#8221;,<br />
myFullName: function(){<br />
console.log(myName.firstName+&#8221; &#8220;+myName.lastName);<br />
}<br />
};<br />
[/js]</p>
<p>So the code <em>myName.myFullName();</em> will return my full name &#8220;Sibeesh Venu&#8221; as output. Right? So from the above code, we can create a functions in JavaScript as follows?</p>
<p>[js]<br />
var myFullName = function(firstName, lastName){<br />
return firstName + &#8221; &#8221; + lastName;<br />
}<br />
[/js]</p>
<p>If you call the above fucntion as preceding, you will get an output as &#8220;Sibeesh Venu&#8221;</p>
<p>[js]<br />
console.log(myFullName(&#8220;Sibeesh&#8221;,&#8221;Venu&#8221;));<br />
[/js]</p>
<p>The question is, what if we are passing only one values? Let&#8217;s try that out.</p>
<p>[js]<br />
console.log(myFullName(&#8220;Sibeesh&#8221;));<br />
[/js]</p>
<p>If you are working in any server side languages, this will actually give an error like &#8220;fucntion with one parameter couldn&#8217;t find&#8221;. But JavaScript is not like that, even if you are wrong, it will try to make you are right. So in this case, it actually treat the second parameter as undefined and give you an output as &#8220;Sibeesh undefined&#8221;.</p>
<p>That&#8217;s all for today. You can always download the source code attached to see the complete code and application. Happy coding!.</p>
<h3><strong>References</strong></h3>
<ul>
<li><a href="https://www.w3schools.com/js/" target="_blank" rel="noopener">JS</a></li>
</ul>
<h3><strong>See also</strong></h3>
<ul>
<li><a href="http://sibeeshpassion.com/category/JavaScript" target="_blank" rel="noopener">Articles related to JavaScript</a></li>
</ul>
<h3><strong>Conclusion</strong></h3>
<p>Did I miss anything that you may think which is needed? Could you find this post as useful? I hope you liked this article. Please share me your valuable suggestions and feedback.</p>
<h3><strong>Your turn. What do you think?</strong></h3>
<p>A blog isn’t a blog without comments, but do try to stay on topic. If you have a question unrelated to this post, you’re better off posting it on C# Corner, Code Project, Stack Overflow, Asp.Net Forum instead of commenting here. Tweet or email me a link to your question there and I’ll definitely try to help if I can.</p>
<p>Kindest Regards<br />
Sibeesh Venu</p>
]]></content:encoded>
					
					<wfw:commentRss>https://mail.sibeeshpassion.com/do-you-know-javascript-are-you-sure-part-1/feed/</wfw:commentRss>
			<slash:comments>4</slash:comments>
		
		
			</item>
		<item>
		<title>Introduction to Web SQL</title>
		<link>https://mail.sibeeshpassion.com/introduction-to-web-sql/</link>
					<comments>https://mail.sibeeshpassion.com/introduction-to-web-sql/#disqus_thread</comments>
		
		<dc:creator><![CDATA[SibeeshVenu]]></dc:creator>
		<pubDate>Mon, 01 Feb 2016 00:00:39 +0000</pubDate>
				<category><![CDATA[CodeProject]]></category>
		<category><![CDATA[How to]]></category>
		<category><![CDATA[Using Web SQL]]></category>
		<category><![CDATA[Web SQL]]></category>
		<guid isPermaLink="false">http://sibeecst_passion.com/?p=11112</guid>

					<description><![CDATA[In this post we will see some informations about Web SQL. I know you all are familiar with SQL, If not I strongly recommend you to read some basic informations here . As the name implies, Web SQL has so many similarities with SQL. So if you are good in SQL, you will love Web SQL too. Web SQL is an API which helps the developers to do some database operations in client side, like creating database, open the transaction, creating tables, inserting values to tables, deleting values, reading the data. If you need any other way to save some [&#8230;]]]></description>
										<content:encoded><![CDATA[<p>In this post we will see some informations about Web SQL. I know you all are familiar with SQL, If not I strongly recommend you to read some basic informations <a href="http://sibeeshpassion.com/category/database/sql/" target="_blank">here </a>. As the name implies, Web SQL has so many similarities with SQL. So if you are good in SQL, you will love Web SQL too. Web SQL is an API which helps the developers to do some database operations in client side, like creating database, open the transaction, creating tables, inserting values to tables, deleting values, reading the data. If you need any other way to save some data in client side, you can use <a href="http://sibeeshpassion.com/tag/storage-in-html5/" target="_blank">storage mechanisms </a> introduced in HTML5.<br />
Now we will look some of the operations a developer can do with Web SQL. I hope you will like this. </p>
<p><strong>Using the code</strong></p>
<p>As you all know, to work with SQL queries, you must create a database. So the first step we are going to do, is creating the database. </p>
<p><strong>Create/Open Web SQL Database</strong></p>
<p>To create a Web SQL database, we can use a function called openDatabase which has four parameters as follows.</p>
<li>Database name</li>
<li>Version Number</li>
<li>Description</li>
<li>Size</li>
<li>Creation callback.</li>
<blockquote><p> The creation callback gets fired while the database is being created. </p></blockquote>
<p>Now shall we open a Web SQL database with the above mentioned parameters? We can do that by running a query as follows.</p>
<p>[sql]<br />
 var myDBInstance = openDatabase(&#8216;dbsibeeshpassion&#8217;, &#8216;1.0&#8217;, &#8216;This is a client side database&#8217;, 2 * 1024 * 1024);<br />
[/sql]</p>
<p>Here I have given the size of my database as <em>2*1024*1024</em>. In most browsers the size is flexible, but few maintains a limit of 5 MB. As from the above query we have created a Web SQL database. Now we will check whether the DB is creatd successfully or not. </p>
<p>[js]<br />
//check whether the database is created or not.<br />
        if (!myDBInstance) {<br />
            alert(&#8216;Oops, your database was not created&#8217;);<br />
        }<br />
        else {<br />
            var version = myDBInstance.version;<br />
        }<br />
[/js]</p>
<p>Here, you will get an alert if the database is not created. Or you will be able to fetch the version details from the database instance.</p>
<p><div id="attachment_11113" style="width: 660px" class="wp-caption alignnone"><a href="http://sibeeshpassion.com/wp-content/uploads/2016/01/Getting_version_details_from_database_instance-e1452772100543.png"><img decoding="async" aria-describedby="caption-attachment-11113" src="http://sibeeshpassion.com/wp-content/uploads/2016/01/Getting_version_details_from_database_instance-e1452772100543.png" alt="Getting_version_details_from_database_instance" width="650" height="239" class="size-full wp-image-11113" srcset="/wp-content/uploads/2016/01/Getting_version_details_from_database_instance-e1452772100543.png 650w, /wp-content/uploads/2016/01/Getting_version_details_from_database_instance-e1452772100543-300x110.png 300w, /wp-content/uploads/2016/01/Getting_version_details_from_database_instance-e1452772100543-400x147.png 400w" sizes="(max-width: 650px) 100vw, 650px" /></a><p id="caption-attachment-11113" class="wp-caption-text">Getting_version_details_from_database_instance</p></div></p>
<p>Once the database is created, we can start using the transaction as we uses in SQL. </p>
<p><strong>Creating transaction</strong></p>
<p>To create a transaction we can use the following syntax. We can use <em>transaction</em> method from our database instance.</p>
<p>[js]<br />
myDBInstance.transaction(function (tran) {<br />
            });<br />
[/js]</p>
<p>Here myDBInstance is our database instance. And tran is our transaction object which we are going to use for our upcoming operations. Why we uses transaction is, as you all know transaction can be roll backed. For example, if any of the operation throws any error, the transaction will be roll backed so there won&#8217;t be any kind of mismatching data happening. And off course, we can easily manage error logs with the help of transaction. Shall we write queries needed for our operations?</p>
<p>First of all, we will create a table in our database. To execute any queries in Web SQL, you must use the method <em>executesql</em>.</p>
<p>[sql]<br />
 tran.executeSql(&#8216;CREATE TABLE IF NOT EXISTS Users (id unique, Name, MailID)&#8217;);<br />
[/sql]</p>
<p>As you can see we are creating the table <em>Users</em> if it does not exists in the database. As in SQL we are assigning <em>id</em> as a unique key. </p>
<p>Next  thing is we need to insert some rows to our table. </p>
<p>[sql]<br />
 tran.executeSql(&#8216;insert into Users (id, Name, MailID) values (1, &quot;Sibi&quot;,&quot;sibikv4u@gmail.com&quot;)&#8217;);<br />
                tran.executeSql(&#8216;insert into Users (id, Name, MailID) values (2, &quot;Aji&quot;,&quot;ajaybhasy@gmail.com&quot;)&#8217;);<br />
                tran.executeSql(&#8216;insert into Users (id, Name, MailID) values (3, &quot;Ansu&quot;,&quot;ansary.ans21@gmail.com&quot;)&#8217;);<br />
[/sql]</p>
<p>If you want to assign name, mailid, id values to insert query, you are welcomed to create those variables and assign to the query as shown below.</p>
<p>[js]<br />
var name = &quot;Sibi&quot;;<br />
            var id = &quot;1&quot;;<br />
            var MailID = &quot;sibikv4u@gmail.com&quot;;</p>
<p> tran.executeSql(&#8216;insert into Users (id, Name, MailID) values (?,?,?)&#8217;,[id,name,MailID]);<br />
[/js]</p>
<p>So we have inserted some values too. Now we need to read the data we have inserted to our table right? To do that we can use we need to create a new transaction and another executeSql command. </p>
<p>[js]<br />
 tran.executeSql(&#8216;SELECT * FROM Users&#8217;, [], function (tran, data) {<br />
                });<br />
[/js]</p>
<p>Here we will get the output in <em>data</em>. As you can see I have given a call back function along with the command. This can be used to loop through our data and shows the same in our page. So we can modify our reading transaction block as follows.</p>
<p>[js]<br />
 myDBInstance.transaction(function (tran) {<br />
                var html = &#8216;&lt;table&gt;&lt;thead&gt;&lt;th&gt;Mail ID &lt;/th&gt;&lt;th&gt;ID&lt;/th&gt;&lt;th&gt;Name &lt;/th&gt;&lt;/thead&gt;&lt;tbody&gt;&#8217;;<br />
                tran.executeSql(&#8216;SELECT * FROM Users&#8217;, [], function (tran, data) {<br />
                    for (i = 0; i &lt; data.rows.length; i++) {<br />
                        html += &#8216;&lt;tr&gt;&lt;td&gt;&#8217;<br />
                            + &#8216;&lt;a &#8216; + &#8216;href=&quot;mailto:&#8217; + data.rows[i].MailID + &#8216;&quot;&gt;&#8217; + data.rows[0].MailID + &#8216;&lt;/a&gt;&#8217; +<br />
                        &#8216;&lt;/td&gt;&lt;td&gt;&#8217; + data.rows[i].id + &#8216;&lt;/td&gt;&lt;td&gt;&#8217; + data.rows[i].Name + &#8216;&lt;/td&gt;&lt;/tr&gt;&#8217;;<br />
                    };<br />
                    html += &#8216;&lt;/tbody&gt;&lt;/table&gt;&#8217;;<br />
                    $(&#8216;#myTab&#8217;).html(html);<br />
                });<br />
            });<br />
[/js]</p>
<p>Before that,</p>
<li>Please don&#8217;t forget to include jQuery reference</li>
<li>Do not forget to create a div with id myTab</li>
<p>You can add a CSS for the table we are creating dynamically as follows.</p>
<p>[css]<br />
&lt;style&gt;<br />
        table,tr,td,th {<br />
            border:1px solid #ccc;<br />
            border-radius:5px;<br />
            padding:10px;<br />
            margin:10px;<br />
        }</p>
<p>    &lt;/style&gt;<br />
[/css]</p>
<p><strong>Complete code</strong></p>
<p>Complete code for the implementation is given below.</p>
<p>[html]<br />
&lt;!DOCTYPE html&gt;<br />
&lt;html xmlns=&quot;http://www.w3.org/1999/xhtml&quot;&gt;<br />
&lt;head&gt;<br />
    &lt;title&gt;Introduction to Web SQL&lt;/title&gt;<br />
    &lt;script src=&quot;Scripts/jquery-1.11.1.min.js&quot;&gt;&lt;/script&gt;<br />
    &lt;script type=&quot;text/javascript&quot;&gt;<br />
        var myDBInstance = openDatabase(&#8216;dbsibeeshpassion&#8217;, &#8216;1.0&#8217;, &#8216;This is a client side database&#8217;, 3 * 1024 * 1024);<br />
        //check whether the database is created or not.<br />
        if (!myDBInstance) {<br />
            alert(&#8216;Oops, your database was not created&#8217;);<br />
        }<br />
        else {<br />
            var version = myDBInstance.version;<br />
            //var name = &quot;Sibi&quot;;<br />
            //var id = &quot;1&quot;;<br />
            //var MailID = &quot;sibikv4u@gmail.com&quot;;<br />
            myDBInstance.transaction(function (tran) {<br />
                tran.executeSql(&#8216;CREATE TABLE IF NOT EXISTS Users (id unique, Name, MailID)&#8217;);<br />
                //tran.executeSql(&#8216;insert into Users (id, Name, MailID) values (?,?,?)&#8217;, [id, name, MailID]);<br />
                tran.executeSql(&#8216;insert into Users (id, Name, MailID) values (1, &quot;Sibi&quot;,&quot;sibikv4u@gmail.com&quot;)&#8217;);<br />
                tran.executeSql(&#8216;insert into Users (id, Name, MailID) values (2, &quot;Aji&quot;,&quot;ajaybhasy@gmail.com&quot;)&#8217;);<br />
                tran.executeSql(&#8216;insert into Users (id, Name, MailID) values (3, &quot;Ansu&quot;,&quot;ansary.ans21@gmail.com&quot;)&#8217;);<br />
            });<br />
            myDBInstance.transaction(function (tran) {<br />
                var html = &#8216;&lt;table&gt;&lt;thead&gt;&lt;th&gt;Mail ID &lt;/th&gt;&lt;th&gt;ID&lt;/th&gt;&lt;th&gt;Name &lt;/th&gt;&lt;/thead&gt;&lt;tbody&gt;&#8217;;<br />
                tran.executeSql(&#8216;SELECT * FROM Users&#8217;, [], function (tran, data) {<br />
                    for (i = 0; i &lt; data.rows.length; i++) {<br />
                        html += &#8216;&lt;tr&gt;&lt;td&gt;&#8217;<br />
                            + &#8216;&lt;a &#8216; + &#8216;href=&quot;mailto:&#8217; + data.rows[i].MailID + &#8216;&quot;&gt;&#8217; + data.rows[0].MailID + &#8216;&lt;/a&gt;&#8217; +<br />
                        &#8216;&lt;/td&gt;&lt;td&gt;&#8217; + data.rows[i].id + &#8216;&lt;/td&gt;&lt;td&gt;&#8217; + data.rows[i].Name + &#8216;&lt;/td&gt;&lt;/tr&gt;&#8217;;<br />
                    };<br />
                    html += &#8216;&lt;/tbody&gt;&lt;/table&gt;&#8217;;<br />
                    $(&#8216;#myTab&#8217;).html(html);<br />
                });<br />
            });<br />
        }</p>
<p>    &lt;/script&gt;<br />
    &lt;style&gt;<br />
        table,tr,td,th {<br />
            border:1px solid #ccc;<br />
            border-radius:5px;<br />
            padding:10px;<br />
            margin:10px;<br />
        }</p>
<p>    &lt;/style&gt;<br />
&lt;/head&gt;<br />
&lt;body&gt;<br />
    &lt;div id=&quot;myTab&quot;&gt;&lt;/div&gt;<br />
&lt;/body&gt;<br />
&lt;/html&gt;<br />
[/html]</p>
<p><strong>Output</strong></p>
<p><div id="attachment_11115" style="width: 329px" class="wp-caption alignnone"><a href="http://sibeeshpassion.com/wp-content/uploads/2016/01/Web_SQL_Output.png"><img decoding="async" aria-describedby="caption-attachment-11115" src="http://sibeeshpassion.com/wp-content/uploads/2016/01/Web_SQL_Output.png" alt="Web_SQL_Output" width="319" height="256" class="size-full wp-image-11115" srcset="/wp-content/uploads/2016/01/Web_SQL_Output.png 319w, /wp-content/uploads/2016/01/Web_SQL_Output-300x241.png 300w" sizes="(max-width: 319px) 100vw, 319px" /></a><p id="caption-attachment-11115" class="wp-caption-text">Web_SQL_Output</p></div></p>
<p>That is all. We did it. Have a happy coding.</p>
<p><strong>Conclusion</strong></p>
<p>Did I miss anything that you may think which is needed? Did you try Web SQL yet? Have you ever wanted to do this requirement? Could you find this post as useful? I hope you liked this article. Please share me your valuable suggestions and feedback.</p>
<p><strong>Your turn. What do you think?</strong></p>
<p>A blog isn’t a blog without comments, but do try to stay on topic. If you have a question unrelated to this post, you’re better off posting it on C# Corner, Code Project, Stack Overflow, Asp.Net Forum instead of commenting here. Tweet or email me a link to your question there and I’ll definitely try to help if I can.</p>
<p>Kindest Regards<br />
Sibeesh Venu</p>
]]></content:encoded>
					
					<wfw:commentRss>https://mail.sibeeshpassion.com/introduction-to-web-sql/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
		<item>
		<title>Hoisting In JavaScript</title>
		<link>https://mail.sibeeshpassion.com/hoisting-in-javascript/</link>
					<comments>https://mail.sibeeshpassion.com/hoisting-in-javascript/#disqus_thread</comments>
		
		<dc:creator><![CDATA[SibeeshVenu]]></dc:creator>
		<pubDate>Fri, 06 Nov 2015 12:19:21 +0000</pubDate>
				<category><![CDATA[CodeProject]]></category>
		<category><![CDATA[JavaScript]]></category>
		<category><![CDATA[JQuery]]></category>
		<category><![CDATA[Hoisting]]></category>
		<category><![CDATA[Javascript]]></category>
		<guid isPermaLink="false">http://sibeecst_passion.com/?p=10955</guid>

					<description><![CDATA[In this post we will discuss the importance and limitations of Hoisting in JavaScript. We all writes client side codes. Right? But few of you might not be aware of the term Hoisting. Hoisting is one of the default behaviour of JavaScript, it is the process of moving all the declarations of the variables to the top of the current function or scope. In this post we will explain this Hoisting in detail with some examples. I hope you will like this. Background I used to spend more time with the client side codes rather than server side codes. In [&#8230;]]]></description>
										<content:encoded><![CDATA[<p>In this post we will discuss the importance and limitations of Hoisting in <a href="http://sibeeshpassion.com/category/javascript/" target="_blank">JavaScript</a>. We all writes client side codes. Right? But few of you might not be aware of the term Hoisting. Hoisting is one of the default behaviour of JavaScript, it is the process of moving all the declarations of the variables to the top of the current function or scope. In this post we will explain this Hoisting in detail with some examples. I hope you will like this. </p>
<p><strong>Background</strong></p>
<p>I used to spend more time with the client side codes rather than server side codes. In my thought is is always good if you do the formation of your data in client side instead doing it in the server side. Client side loops are always faster than the server side ones. As a client side code developer, you must understand the word Hoisting in JavaScript. Here we will discuss that.</p>
<p><strong>Using the code</strong></p>
<p>Before going through we need to know some facts in JavaScript. </p>
<p><em>Do you know?</em></p>
<p>In JavaScript we can use any variable before it is declared or a variable can be declared after it is used. </p>
<p>For Example: </p>
<p>The below two scripts will return same output.</p>
<p>[js]<br />
&lt;script&gt;<br />
x = 5;<br />
alert(x);<br />
var x;<br />
&lt;/script&gt;<br />
[/js]</p>
<p>And </p>
<p>[js]<br />
&lt;script&gt;<br />
var x;<br />
x = 5;<br />
alert(x);<br />
&lt;/script&gt;<br />
[/js]</p>
<p><strong>Limitations of Hoisting</strong></p>
<p>Even though the process of Hosting will move the declarations to the top, there is some limitations too. We will discuss it here now.</p>
<blockquote><p>Initializing a variable can not be Hoisted or In simple JavaScript Hoists declarations not initializations. </p></blockquote>
<p>For Example:</p>
<p>The below scripts will give different outputs.</p>
<p>[js]<br />
&lt;script&gt;<br />
var x = 2;<br />
var y = 4;<br />
alert(x+y);<br />
&lt;/script&gt;<br />
[/js]</p>
<p>This will give you an output of 6.</p>
<p>And </p>
<p>[js]<br />
&lt;script&gt;<br />
var x = 2;<br />
alert(x+y);<br />
var y = 4;<br />
&lt;/script&gt;<br />
[/js]</p>
<p>This will give you an output of NaN. Since we are initializing the value of y, the JavaScript Hoisting is not happening, so the y value will be undefined. The JavaScript will consider that y is not yet declared. </p>
<p>So the second example is same as of below.</p>
<p>[js]<br />
&lt;script&gt;<br />
var x = 2;<br />
var y;<br />
alert(x+y);<br />
y = 4;<br />
&lt;/script&gt;<br />
[/js]</p>
<p>This will give you an output of NaN.</p>
<p><div id="attachment_10956" style="width: 403px" class="wp-caption alignnone"><a href="http://sibeeshpassion.com/wp-content/uploads/2015/11/Hoisting-In-JavaScript.png"><img decoding="async" aria-describedby="caption-attachment-10956" src="http://sibeeshpassion.com/wp-content/uploads/2015/11/Hoisting-In-JavaScript.png" alt="Hoisting In JavaScript" width="393" height="207" class="size-full wp-image-10956" srcset="/wp-content/uploads/2015/11/Hoisting-In-JavaScript.png 393w, /wp-content/uploads/2015/11/Hoisting-In-JavaScript-300x158.png 300w" sizes="(max-width: 393px) 100vw, 393px" /></a><p id="caption-attachment-10956" class="wp-caption-text">Hoisting In JavaScript</p></div></p>
<p><strong>Conclusion</strong></p>
<p>Since we are all developers, it is always makes things simple. So much complexity in software comes from trying to make one thing do two things. So always declare your variables on top of your function or scope. Did I miss anything that you may think which is needed? Could you find this post as useful? I hope you liked this article. Please share me your valuable suggestions and feedback.</p>
<p><strong>Your turn. What do you think?</strong></p>
<p>A blog isn’t a blog without comments, but do try to stay on topic. If you have a question unrelated to this post, you’re better off posting it on C# Corner, Code Project, Stack Overflow, Asp.Net Forum instead of commenting here. Tweet or email me a link to your question there and I’ll definitely try to help if I can.</p>
<p>Kindest Regards<br />
Sibeesh Venu</p>
]]></content:encoded>
					
					<wfw:commentRss>https://mail.sibeeshpassion.com/hoisting-in-javascript/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
		<item>
		<title>Load XML And Show As li In Angular JS</title>
		<link>https://mail.sibeeshpassion.com/load-xml-and-show-as-li-in-angular-js/</link>
					<comments>https://mail.sibeeshpassion.com/load-xml-and-show-as-li-in-angular-js/#disqus_thread</comments>
		
		<dc:creator><![CDATA[SibeeshVenu]]></dc:creator>
		<pubDate>Wed, 04 Nov 2015 05:02:24 +0000</pubDate>
				<category><![CDATA[Angular]]></category>
		<category><![CDATA[CodeProject]]></category>
		<category><![CDATA[$http in Angular JS]]></category>
		<category><![CDATA[Angular JS]]></category>
		<category><![CDATA[Convert XML to JSON In Angular JS]]></category>
		<category><![CDATA[Load XML And Show As li In Angular JS]]></category>
		<category><![CDATA[ng-repeat]]></category>
		<category><![CDATA[XML to LI in Angular JS]]></category>
		<guid isPermaLink="false">http://sibeecst_passion.com/?p=10907</guid>

					<description><![CDATA[In this post we will see how we can load an XML file and show as li using ng-repeat in Angular JS. As you all know Angular JS is a JavaScript framework for developing applications. So basically Angular JS expects the response in the form of JSON. Hence it is recommended to return the data in JSON format before you start to work on the data. Here in this post we will load a local XML file using Angular JS $http service, and we will convert the same XML file to JSON. Once it is converted, we will loop through [&#8230;]]]></description>
										<content:encoded><![CDATA[<p>In this post we will see how we can load an XML file and show as li using ng-repeat in Angular JS. As you all know Angular JS is a JavaScript framework for developing applications. So basically Angular JS expects the response in the form of JSON. Hence it is recommended to return the data in JSON format before you start to work on the data. Here in this post we will load a local XML file using Angular JS $http service, and we will convert the same XML file to JSON. Once it is converted, we will loop through the JSON and show it as li using ng-repeat. If you are new to Angular JS, please read here: <a href="http://sibeeshpassion.com/category/angularjs/" target="_blank">Angular JS</a>. I hope you will like this article. </p>
<p><strong>Background</strong></p>
<p>I have already posted an article related to $http service in Angular JS, you can see here: <a href="http://sibeeshpassion.com/learning-angularjs-http/" target="_blank">$http Service In Angular JS</a></p>
<p>To convert your XML file to JSON, I recommend you to read here: <a href="http://sibeeshpassion.com/convert-xml-to-json-in-angular-js/" target="_blank">XML to JSON In Angular JS</a></p>
<p><strong>Source Code</strong></p>
<p>Please download the source code here: <a href="http://sibeeshpassion.com/download/LOADXMLASLI.rar" target="_blank">XML to Li Source Code</a></p>
<p><strong>Using the code</strong></p>
<p>Create an html page first.</p>
<p>[html]<br />
&lt;!DOCTYPE html&gt;<br />
&lt;html&gt;<br />
&lt;head&gt;<br />
    &lt;title&gt;Load XML And Show As li In Angular JS &#8211; sibeeshpassion &lt;/title&gt;<br />
&lt;/head&gt;<br />
&lt;body&gt;<br />
&lt;/body&gt;<br />
&lt;/html&gt;<br />
[/html]</p>
<p>Now add the needed reference as follows. </p>
<p>[js]<br />
&lt;script src=&quot;jquery-2.1.3.min.js&quot;&gt;&lt;/script&gt;<br />
    &lt;script src=&quot;angular.min.js&quot;&gt;&lt;/script&gt;<br />
    &lt;script src=&quot;xml2json.js&quot;&gt;&lt;/script&gt;<br />
[/js]</p>
<blockquote><p>Have you noticed that I have added xml2json.js file? This is the file which is doing the conversion part. You can always download the file from <a href="https://code.google.com/p/x2js/" target="_blank">https://code.google.com/p/x2js/</a></p></blockquote>
<p>So if you read and implement as explained in my article on converting XML file to JSON in Angular JS, Your page will be looking as follows. </p>
<p>[html]<br />
&lt;!DOCTYPE html&gt;<br />
&lt;html&gt;<br />
&lt;head&gt;<br />
    &lt;title&gt;Convert XML to JSON In Angular JS &#8211; sibeeshpassion &lt;/title&gt;<br />
    &lt;script src=&quot;jquery-2.1.3.min.js&quot;&gt;&lt;/script&gt;<br />
    &lt;script src=&quot;angular.min.js&quot;&gt;&lt;/script&gt;<br />
    &lt;script src=&quot;xml2json.js&quot;&gt;&lt;/script&gt;<br />
&lt;/head&gt;<br />
&lt;body&gt;<br />
    &lt;div ng-app=&quot;httpApp&quot; ng-controller=&quot;httpController&quot;&gt;<br />
    &lt;/div&gt;<br />
    &lt;script&gt;<br />
        var app = angular.module(&#8216;httpApp&#8217;, []);<br />
        app.controller(&#8216;httpController&#8217;, function ($scope, $http) {<br />
            $http.get(&quot;Sitemap.xml&quot;,<br />
                    {<br />
                        transformResponse: function (cnv) {<br />
                            var x2js = new X2JS();<br />
                            var aftCnv = x2js.xml_str2json(cnv);<br />
                            return aftCnv;<br />
                        }<br />
                    })<br />
            .success(function (response) {<br />
                console.log(response);<br />
            });<br />
        });<br />
    &lt;/script&gt;<br />
&lt;/body&gt;<br />
&lt;/html&gt;<br />
[/html]</p>
<p>So we have loaded our XML and converted the it to the JSON. Now we need to show this JSON response as li using ng-repeat in Angular JS. Are you ready?</p>
<p>For that please change your ng-app directive as follows.</p>
<p>[html]<br />
&lt;div ng-app=&quot;httpApp&quot; ng-controller=&quot;httpController&quot;&gt;<br />
        &lt;ul&gt;<br />
            &lt;li ng-repeat=&quot;det in details&quot;&gt;&lt;a href=&quot;{{det.loc }}&quot;&gt;{{det.loc }}&lt;/a&gt;<br />
            &lt;/li&gt;<br />
        &lt;/ul&gt;<br />
    &lt;/div&gt;<br />
[/html]</p>
<p>And we can change our Angular script implementation as below.</p>
<p>[js]<br />
  &lt;script&gt;<br />
        var app = angular.module(&#8216;httpApp&#8217;, []);<br />
        app.controller(&#8216;httpController&#8217;, function ($scope, $http) {<br />
            $http.get(&quot;Sitemap.xml&quot;,<br />
                    {<br />
                        transformResponse: function (cnv) {<br />
                            var x2js = new X2JS();<br />
                            var aftCnv = x2js.xml_str2json(cnv);<br />
                            return aftCnv;<br />
                        }<br />
                    })<br />
            .success(function (response) {<br />
                $scope.details = response.urlset.url;<br />
                console.log(response);<br />
            });<br />
        });<br />
    &lt;/script&gt;<br />
[/js]</p>
<p>So we are assigning response.urlset.url to the $scope.details so that we can simply loop through using ng-repeat as<br />
<em>det in details</em>. </p>
<p>If you download the sitemap.xml file from the source code given you can get to know the XML structure of the data. Depends on the data structure we need to assign the response to the $scope. </p>
<p>I guess everything is done, now we can see the output. </p>
<p><strong>Output</strong></p>
<p><div id="attachment_10922" style="width: 660px" class="wp-caption alignnone"><a href="http://sibeeshpassion.com/wp-content/uploads/2015/11/Load-XML-And-Show-As-li-In-Angular-JS-e1446613118202.png"><img decoding="async" aria-describedby="caption-attachment-10922" src="http://sibeeshpassion.com/wp-content/uploads/2015/11/Load-XML-And-Show-As-li-In-Angular-JS-e1446613118202.png" alt="Load XML And Show As li In Angular JS" width="650" height="561" class="size-full wp-image-10922" srcset="/wp-content/uploads/2015/11/Load-XML-And-Show-As-li-In-Angular-JS-e1446613118202.png 650w, /wp-content/uploads/2015/11/Load-XML-And-Show-As-li-In-Angular-JS-e1446613118202-300x259.png 300w, /wp-content/uploads/2015/11/Load-XML-And-Show-As-li-In-Angular-JS-e1446613118202-400x345.png 400w" sizes="(max-width: 650px) 100vw, 650px" /></a><p id="caption-attachment-10922" class="wp-caption-text">Load XML And Show As li In Angular JS</p></div></p>
<p>That&#8217;s all we have done everything. Happy coding!.</p>
<p><strong>Complete Code</strong></p>
<p>[html]<br />
&lt;!DOCTYPE html&gt;<br />
&lt;html&gt;<br />
&lt;head&gt;<br />
    &lt;title&gt;Load XML And Show As li In Angular JS &#8211; sibeeshpassion &lt;/title&gt;<br />
    &lt;script src=&quot;jquery-2.1.3.min.js&quot;&gt;&lt;/script&gt;<br />
    &lt;script src=&quot;angular.min.js&quot;&gt;&lt;/script&gt;<br />
    &lt;script src=&quot;xml2json.js&quot;&gt;&lt;/script&gt;<br />
&lt;/head&gt;<br />
&lt;body&gt;<br />
    &lt;div ng-app=&quot;httpApp&quot; ng-controller=&quot;httpController&quot;&gt;<br />
        &lt;ul&gt;<br />
            &lt;li ng-repeat=&quot;det in details&quot;&gt;&lt;a href=&quot;{{det.loc }}&quot;&gt;{{det.loc }}&lt;/a&gt;<br />
            &lt;/li&gt;<br />
        &lt;/ul&gt;<br />
    &lt;/div&gt;<br />
    &lt;script&gt;<br />
        var app = angular.module(&#8216;httpApp&#8217;, []);<br />
        app.controller(&#8216;httpController&#8217;, function ($scope, $http) {<br />
            $http.get(&quot;Sitemap.xml&quot;,<br />
                    {<br />
                        transformResponse: function (cnv) {<br />
                            var x2js = new X2JS();<br />
                            var aftCnv = x2js.xml_str2json(cnv);<br />
                            return aftCnv;<br />
                        }<br />
                    })<br />
            .success(function (response) {<br />
                $scope.details = response.urlset.url;<br />
                console.log(response);<br />
            });<br />
        });<br />
    &lt;/script&gt;<br />
&lt;/body&gt;<br />
&lt;/html&gt;<br />
[/html]</p>
<p><strong>Conclusion</strong></p>
<p>Did I miss anything that you may think which is needed? Could you find this post as useful? I hope you liked this article. Please share me your valuable suggestions and feedback.</p>
<p><strong>Your turn. What do you think?</strong></p>
<p>A blog isn’t a blog without comments, but do try to stay on topic. If you have a question unrelated to this post, you’re better off posting it on C# Corner, Code Project, Stack Overflow, Asp.Net Forum instead of commenting here. Tweet or email me a link to your question there and I’ll definitely try to help if I can.</p>
<p>Kindest Regards<br />
Sibeesh Venu</p>
]]></content:encoded>
					
					<wfw:commentRss>https://mail.sibeeshpassion.com/load-xml-and-show-as-li-in-angular-js/feed/</wfw:commentRss>
			<slash:comments>4</slash:comments>
		
		
			</item>
		<item>
		<title>Function Declaration And Function Expression</title>
		<link>https://mail.sibeeshpassion.com/function-declaration-and-function-expression/</link>
					<comments>https://mail.sibeeshpassion.com/function-declaration-and-function-expression/#disqus_thread</comments>
		
		<dc:creator><![CDATA[SibeeshVenu]]></dc:creator>
		<pubDate>Wed, 21 Oct 2015 00:59:00 +0000</pubDate>
				<category><![CDATA[CodeProject]]></category>
		<category><![CDATA[JavaScript]]></category>
		<category><![CDATA[JQuery]]></category>
		<category><![CDATA[Difference between function declaration and function expression]]></category>
		<category><![CDATA[Function Declaration And Function Expression]]></category>
		<guid isPermaLink="false">http://sibeecst_passion.com/?p=10821</guid>

					<description><![CDATA[In this post we will see the basic difference between function declaration and function expression in jQuery and JavaScript. Sometimes the developer&#8217;s getting confused between these two topics(Shhhh I ma saying about the starters like me). Basically both are same. Only difference is depends on how you handle or treat these two. We will see a basic demo here to ensure the difference between function declaration and expression. I hope you will like this. Here I am using jQuery 2.0.2 version, you can use whichever version you like. Background In my projects I am using both function declarations and function [&#8230;]]]></description>
										<content:encoded><![CDATA[<p>In this post we will see the basic difference between function declaration and function expression in jQuery and JavaScript. Sometimes the developer&#8217;s getting confused between these two topics(Shhhh I ma saying about the starters like me). Basically both are same. Only difference is depends on how you handle or treat these two. We will see a basic demo here to ensure the difference between function declaration and expression. I hope you will like this.</p>
<blockquote><p>Here I am using jQuery 2.0.2 version, you can use whichever version you like. </p></blockquote>
<p><strong>Background</strong></p>
<p>In my projects I am using both function declarations and function expressions. So I thought to highlight some basic difference between them, so that it may help someone. </p>
<p><strong>Basic Difference Between Function Declaration And Function Definition</strong></p>
<li>Function declarations are loaded first, that is before any codes</li>
<li>Function expressions are loaded when the interpreter reaches that particular line of code.</li>
<li>Basically we can call any code only after the declarations are loaded</li>
<p>We will try to find out this difference with a demo.</p>
<p><strong>Using the code</strong></p>
<p>First thing you need to do is create a page.</p>
<p>[html]<br />
&lt;!DOCTYPE html&gt;<br />
&lt;html&gt;<br />
&lt;head&gt;<br />
    &lt;title&gt;Function Declaration VS Expression &#8211; Sibeesh Passion&lt;/title&gt;<br />
&lt;/head&gt;<br />
&lt;body&gt;<br />
   Function Declaration VS Expression &#8211; Sibeesh Passion<br />
&lt;/body&gt;<br />
&lt;/html&gt;<br />
[/html]</p>
<p>Then you need to include the script needed.</p>
<p>[js]<br />
&lt;script src=&quot;http://sibeeshpassion.com/content/scripts/jquery-2.0.2.min.js&quot;&gt;&lt;/script&gt;<br />
[/js]</p>
<p>Now we will create a function declaration as follows. </p>
<p>[js]<br />
&lt;script&gt;<br />
        $(document).ready(function () {<br />
		   alert(myFunctionDeclaration());<br />
           function myFunctionDeclaration()<br />
		   {<br />
				return &#8216;myFunctionDeclaration is called&#8217;;<br />
		   }<br />
        });<br />
    &lt;/script&gt;<br />
[/js]</p>
<p>What will be the output of this?</p>
<p><div id="attachment_10822" style="width: 391px" class="wp-caption alignnone"><a href="http://sibeeshpassion.com/wp-content/uploads/2015/10/Function_Declaration_And_Function_Expression.png"><img decoding="async" aria-describedby="caption-attachment-10822" src="http://sibeeshpassion.com/wp-content/uploads/2015/10/Function_Declaration_And_Function_Expression.png" alt="Function Declaration And Function Expression " width="381" height="231" class="size-full wp-image-10822" srcset="/wp-content/uploads/2015/10/Function_Declaration_And_Function_Expression.png 381w, /wp-content/uploads/2015/10/Function_Declaration_And_Function_Expression-300x182.png 300w" sizes="(max-width: 381px) 100vw, 381px" /></a><p id="caption-attachment-10822" class="wp-caption-text">Function Declaration And Function Expression</p></div></p>
<p>Now we will change our script as follows. </p>
<p>[js]<br />
&lt;script&gt;<br />
        $(document).ready(function () {<br />
           function myFunctionDeclaration()<br />
		   {<br />
				return &#8216;myFunctionDeclaration is called&#8217;;<br />
		   }<br />
		   alert(myFunctionDeclaration());<br />
        });<br />
    &lt;/script&gt;<br />
[/js]</p>
<p>This will also returns the same output.</p>
<p><div id="attachment_10822" style="width: 391px" class="wp-caption alignnone"><a href="http://sibeeshpassion.com/wp-content/uploads/2015/10/Function_Declaration_And_Function_Expression.png"><img decoding="async" aria-describedby="caption-attachment-10822" src="http://sibeeshpassion.com/wp-content/uploads/2015/10/Function_Declaration_And_Function_Expression.png" alt="Function Declaration And Function Expression " width="381" height="231" class="size-full wp-image-10822" srcset="/wp-content/uploads/2015/10/Function_Declaration_And_Function_Expression.png 381w, /wp-content/uploads/2015/10/Function_Declaration_And_Function_Expression-300x182.png 300w" sizes="(max-width: 381px) 100vw, 381px" /></a><p id="caption-attachment-10822" class="wp-caption-text">Function Declaration And Function Expression</p></div></p>
<p>Now we will create a function expression as follows. </p>
<p>[js]<br />
&lt;script&gt;<br />
        $(document).ready(function () {<br />
		  alert(myFunctionExpression());<br />
		   var myFunctionExpression = function()<br />
		   {<br />
				return &#8216;myFunctionExpression is called&#8217;;<br />
		   }<br />
        });<br />
    &lt;/script&gt;<br />
[/js]</p>
<p>What may be the output of this? We will check it now. </p>
<p><div id="attachment_10823" style="width: 427px" class="wp-caption alignnone"><a href="http://sibeeshpassion.com/wp-content/uploads/2015/10/Function_Declaration_And_Function_Expression1.png"><img decoding="async" aria-describedby="caption-attachment-10823" src="http://sibeeshpassion.com/wp-content/uploads/2015/10/Function_Declaration_And_Function_Expression1.png" alt="Function Declaration And Function Expression " width="417" height="282" class="size-full wp-image-10823" srcset="/wp-content/uploads/2015/10/Function_Declaration_And_Function_Expression1.png 417w, /wp-content/uploads/2015/10/Function_Declaration_And_Function_Expression1-300x203.png 300w, /wp-content/uploads/2015/10/Function_Declaration_And_Function_Expression1-400x271.png 400w" sizes="(max-width: 417px) 100vw, 417px" /></a><p id="caption-attachment-10823" class="wp-caption-text">Function Declaration And Function Expression</p></div></p>
<p>As you can see, instead of giving an alert it is throwing an error <em>Uncaught TypeError: myFunctionExpression is not a function</em> in the console. It is just because the function expression is not yet loaded. You are trying to call that expression before it loads.</p>
<p>So what we can do to make it work? Simple, just change the script as follows.</p>
<p>[js]<br />
&lt;script&gt;<br />
        $(document).ready(function () {<br />
                   var myFunctionExpression = function()<br />
		   {<br />
				return &#8216;myFunctionExpression is called&#8217;;<br />
		   }<br />
		   alert(myFunctionExpression());<br />
        });<br />
    &lt;/script&gt;<br />
[/js]</p>
<p>Now you will get an alert as follows.</p>
<p><div id="attachment_10824" style="width: 397px" class="wp-caption alignnone"><a href="http://sibeeshpassion.com/wp-content/uploads/2015/10/Function_Declaration_And_Function_Expression2.png"><img decoding="async" aria-describedby="caption-attachment-10824" src="http://sibeeshpassion.com/wp-content/uploads/2015/10/Function_Declaration_And_Function_Expression2.png" alt="Function Declaration And Function Expression " width="387" height="207" class="size-full wp-image-10824" srcset="/wp-content/uploads/2015/10/Function_Declaration_And_Function_Expression2.png 387w, /wp-content/uploads/2015/10/Function_Declaration_And_Function_Expression2-300x160.png 300w" sizes="(max-width: 387px) 100vw, 387px" /></a><p id="caption-attachment-10824" class="wp-caption-text">Function Declaration And Function Expression</p></div></p>
<p>That is all. I hope you know the difference between function declaration and function expression now. </p>
<p><strong>Complete Code</strong></p>
<p>[html]<br />
&lt;!DOCTYPE html&gt;<br />
&lt;html&gt;<br />
&lt;head&gt;<br />
    &lt;title&gt;Function Declaration VS Expression &#8211; Sibeesh Passion&lt;/title&gt;<br />
    &lt;script src=&quot;http://sibeeshpassion.com/content/scripts/jquery-2.0.2.min.js&quot;&gt;&lt;/script&gt;<br />
    &lt;script&gt;<br />
        $(document).ready(function () {</p>
<p>		   var myFunctionExpression = function()<br />
		   {<br />
				return &#8216;myFunctionExpression is called&#8217;;<br />
		   }<br />
		   alert(myFunctionExpression());<br />
		   alert(myFunctionDeclaration());<br />
           function myFunctionDeclaration()<br />
		   {<br />
				return &#8216;myFunctionDeclaration is called&#8217;;<br />
		   }<br />
        });<br />
    &lt;/script&gt;<br />
&lt;/head&gt;<br />
&lt;body&gt;<br />
    Function Declaration VS Expression &#8211; Sibeesh Passion<br />
	&lt;div class=&quot;first&quot;&gt;&lt;/div&gt;<br />
&lt;/body&gt;<br />
&lt;/html&gt;</p>
<p>[/html]</p>
<p><strong>Conclusion</strong></p>
<p>Did I miss anything that you may think which is needed? Could you find this post as useful? I hope you liked this article. Please share me your valuable suggestions and feedback.</p>
<p><strong>Your turn. What do you think?</strong></p>
<p>A blog isn’t a blog without comments, but do try to stay on topic. If you have a question unrelated to this post, you’re better off posting it on C# Corner, Code Project, Stack Overflow, Asp.Net Forum instead of commenting here. Tweet or email me a link to your question there and I’ll definitely try to help if I can.</p>
<p>Kindest Regards<br />
Sibeesh Venu</p>
]]></content:encoded>
					
					<wfw:commentRss>https://mail.sibeeshpassion.com/function-declaration-and-function-expression/feed/</wfw:commentRss>
			<slash:comments>6</slash:comments>
		
		
			</item>
		<item>
		<title>Find Browser And Browser Version Using jQuery</title>
		<link>https://mail.sibeeshpassion.com/find-browser-and-browser-version-using-jquery/</link>
					<comments>https://mail.sibeeshpassion.com/find-browser-and-browser-version-using-jquery/#disqus_thread</comments>
		
		<dc:creator><![CDATA[SibeeshVenu]]></dc:creator>
		<pubDate>Wed, 21 Oct 2015 00:17:20 +0000</pubDate>
				<category><![CDATA[CodeProject]]></category>
		<category><![CDATA[JQuery]]></category>
		<category><![CDATA[Browser]]></category>
		<category><![CDATA[Find Browser And Browser Version Using jQuery]]></category>
		<category><![CDATA[jQuery Browser]]></category>
		<category><![CDATA[jquery functions]]></category>
		<guid isPermaLink="false">http://sibeecst_passion.com/?p=10805</guid>

					<description><![CDATA[In this post we will see how we can find out the browser name and browser version by using jQuery. Here we will be using $.browser property og jQuery which returns the browser information. In this demo we will test this in most used browsers like Internet Explorer, Mozilla, Chrome, Opera. I hope you will like this. NB: Using $.browser is not recommended by jQuery itself, so that this feature has been moved to the jQuery.migrate plugin which is available to download if the user want. It is a vulnerable practice to use the same. Use it only if needed. [&#8230;]]]></description>
										<content:encoded><![CDATA[<p>In this post we will see how we can find out the browser name and browser version by using jQuery. Here we will be using $.browser property og jQuery which returns the browser information. In this demo we will test this in most used browsers like Internet Explorer, Mozilla, Chrome, Opera. I hope you will like this.</p>
<blockquote><p>NB: Using $.browser is not recommended by jQuery itself, so that this feature has been moved to the jQuery.migrate plugin which is available to download if the user want. It is a vulnerable practice to use the same. Use it only if needed. It is always better to do not use browser specific codes. </p></blockquote>
<p><strong>Using the code</strong></p>
<p>First thing you need to do is create a page.</p>
<p>[html]<br />
&lt;!DOCTYPE html&gt;<br />
&lt;html&gt;<br />
&lt;head&gt;<br />
    &lt;title&gt;Find Browser In JQuery &#8211; Sibeesh Passion&lt;/title&gt;<br />
&lt;/head&gt;<br />
&lt;body&gt;<br />
    Find Browser In JQuery &#8211; Sibeesh Passion<br />
&lt;/body&gt;<br />
&lt;/html&gt;<br />
[/html]</p>
<p>Then you need to include the script needed.</p>
<p>[js]<br />
&lt;script src=&quot;http://sibeeshpassion.com/content/scripts/jquery-2.0.2.min.js&quot;&gt;&lt;/script&gt;<br />
    &lt;script src=&quot;http://code.jquery.com/jquery-migrate-1.2.1.js&quot;&gt;&lt;/script&gt;<br />
[/js]</p>
<p>As you have noticed I have included <em>http://code.jquery.com/jquery-migrate-1.2.1.js</em>. It is just because this feature is deprecated and moved to this js. </p>
<p>Now you need to write the scripts.</p>
<p>[js]<br />
&lt;script&gt;<br />
        $(document).ready(function () {<br />
            if ($.browser.webkit) {<br />
                alert(&quot;Hooray WebKit!&quot; +&quot; Version: &quot;+ $.browser.version);<br />
            } else if ($.browser.msie) {<br />
                alert(&quot;Hooray IE!&quot; + &quot; Version: &quot; + $.browser.version);<br />
            } else if ($.browser.mozilla) {<br />
                alert(&quot;Hooray mozilla!&quot; + &quot; Version: &quot; + $.browser.version);<br />
            }<br />
            $.each($.browser, function (i, val) {<br />
                $(&quot;&lt;div&gt;&quot; + i + &quot; : &lt;span&gt;&quot; + val + &quot;&lt;/span&gt;&quot;)<br />
                .appendTo(document.body);<br />
            });<br />
        });<br />
    &lt;/script&gt;<br />
[/js]</p>
<p>We are appending the browser details to the DOM. So that it is always better to use some CSS to improve the readability.</p>
<p>[css]<br />
 &lt;style&gt;<br />
        div {<br />
            width: 500px;<br />
            border: 1px solid #ccc;<br />
            border-radius: 5px;<br />
            padding: 10px;<br />
            margin: 10px;<br />
            box-shadow: 1px 1px 1px #999;<br />
            color: #f90;<br />
            font-style: oblique;<br />
            text-align: center;<br />
        }<br />
    &lt;/style&gt;<br />
[/css]</p>
<p>Now please run your browser, you can see the following output. </p>
<p><div id="attachment_10806" style="width: 427px" class="wp-caption alignnone"><a href="http://sibeeshpassion.com/wp-content/uploads/2015/10/Find_Browser_And_Browser_Version_Using_jQuery.png"><img decoding="async" aria-describedby="caption-attachment-10806" src="http://sibeeshpassion.com/wp-content/uploads/2015/10/Find_Browser_And_Browser_Version_Using_jQuery.png" alt="Find Browser And Browser Version Using jQuery" width="417" height="243" class="size-full wp-image-10806" srcset="/wp-content/uploads/2015/10/Find_Browser_And_Browser_Version_Using_jQuery.png 417w, /wp-content/uploads/2015/10/Find_Browser_And_Browser_Version_Using_jQuery-300x175.png 300w, /wp-content/uploads/2015/10/Find_Browser_And_Browser_Version_Using_jQuery-400x233.png 400w" sizes="(max-width: 417px) 100vw, 417px" /></a><p id="caption-attachment-10806" class="wp-caption-text">Find Browser And Browser Version Using jQuery</p></div></p>
<p><div id="attachment_10807" style="width: 624px" class="wp-caption alignnone"><a href="http://sibeeshpassion.com/wp-content/uploads/2015/10/Find_Browser_And_Browser_Version_Using_jQuery1.png"><img decoding="async" aria-describedby="caption-attachment-10807" src="http://sibeeshpassion.com/wp-content/uploads/2015/10/Find_Browser_And_Browser_Version_Using_jQuery1.png" alt="Find Browser And Browser Version Using jQuery" width="614" height="238" class="size-full wp-image-10807" srcset="/wp-content/uploads/2015/10/Find_Browser_And_Browser_Version_Using_jQuery1.png 614w, /wp-content/uploads/2015/10/Find_Browser_And_Browser_Version_Using_jQuery1-300x116.png 300w, /wp-content/uploads/2015/10/Find_Browser_And_Browser_Version_Using_jQuery1-400x155.png 400w" sizes="(max-width: 614px) 100vw, 614px" /></a><p id="caption-attachment-10807" class="wp-caption-text">Find Browser And Browser Version Using jQuery</p></div></p>
<p><div id="attachment_10808" style="width: 577px" class="wp-caption alignnone"><a href="http://sibeeshpassion.com/wp-content/uploads/2015/10/Find_Browser_And_Browser_Version_Using_jQuery2.png"><img decoding="async" aria-describedby="caption-attachment-10808" src="http://sibeeshpassion.com/wp-content/uploads/2015/10/Find_Browser_And_Browser_Version_Using_jQuery2.png" alt="Find Browser And Browser Version Using jQuery" width="567" height="199" class="size-full wp-image-10808" srcset="/wp-content/uploads/2015/10/Find_Browser_And_Browser_Version_Using_jQuery2.png 567w, /wp-content/uploads/2015/10/Find_Browser_And_Browser_Version_Using_jQuery2-300x105.png 300w, /wp-content/uploads/2015/10/Find_Browser_And_Browser_Version_Using_jQuery2-400x140.png 400w" sizes="(max-width: 567px) 100vw, 567px" /></a><p id="caption-attachment-10808" class="wp-caption-text">Find Browser And Browser Version Using jQuery</p></div></p>
<p><strong>Complete Code</strong></p>
<p>[html]<br />
&lt;!DOCTYPE html&gt;<br />
&lt;html&gt;<br />
&lt;head&gt;<br />
    &lt;title&gt;Find Browser In JQuery &#8211; Sibeesh Passion&lt;/title&gt;<br />
    &lt;script src=&quot;http://sibeeshpassion.com/content/scripts/jquery-2.0.2.min.js&quot;&gt;&lt;/script&gt;<br />
    &lt;script src=&quot;http://code.jquery.com/jquery-migrate-1.2.1.js&quot;&gt;&lt;/script&gt;<br />
    &lt;script&gt;<br />
        $(document).ready(function () {<br />
            if ($.browser.webkit) {<br />
                alert(&quot;Hooray WebKit!&quot; +&quot; Version: &quot;+ $.browser.version);<br />
            } else if ($.browser.msie) {<br />
                alert(&quot;Hooray IE!&quot; + &quot; Version: &quot; + $.browser.version);<br />
            } else if ($.browser.mozilla) {<br />
                alert(&quot;Hooray mozilla!&quot; + &quot; Version: &quot; + $.browser.version);<br />
            }<br />
            $.each($.browser, function (i, val) {<br />
                $(&quot;&lt;div&gt;&quot; + i + &quot; : &lt;span&gt;&quot; + val + &quot;&lt;/span&gt;&quot;)<br />
                .appendTo(document.body);<br />
            });<br />
        });<br />
    &lt;/script&gt;<br />
    &lt;style&gt;<br />
        div {<br />
            width: 500px;<br />
            border: 1px solid #ccc;<br />
            border-radius: 5px;<br />
            padding: 10px;<br />
            margin: 10px;<br />
            box-shadow: 1px 1px 1px #999;<br />
            color: #f90;<br />
            font-style: oblique;<br />
            text-align: center;<br />
        }<br />
    &lt;/style&gt;<br />
&lt;/head&gt;<br />
&lt;body&gt;<br />
    Find Browser In JQuery &#8211; Sibeesh Passion<br />
&lt;/body&gt;<br />
&lt;/html&gt;</p>
<p>[/html]</p>
<p><strong>Conclusion</strong></p>
<p>Did I miss anything that you may think which is needed? Have you ever wanted to find out the browser details in client side? Could you find this post as useful? I hope you liked this article. Please share me your valuable suggestions and feedback.</p>
<p><strong>Your turn. What do you think?</strong></p>
<p>A blog isn’t a blog without comments, but do try to stay on topic. If you have a question unrelated to this post, you’re better off posting it on C# Corner, Code Project, Stack Overflow, Asp.Net Forum instead of commenting here. Tweet or email me a link to your question there and I’ll definitely try to help if I can.</p>
<p>Kindest Regards<br />
Sibeesh Venu</p>
]]></content:encoded>
					
					<wfw:commentRss>https://mail.sibeeshpassion.com/find-browser-and-browser-version-using-jquery/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
		<item>
		<title>jQuery no-conflict And Using Different Versions Of JQuery</title>
		<link>https://mail.sibeeshpassion.com/jquery-no-conflict-and-using-different-versions-of-jquery/</link>
					<comments>https://mail.sibeeshpassion.com/jquery-no-conflict-and-using-different-versions-of-jquery/#disqus_thread</comments>
		
		<dc:creator><![CDATA[SibeeshVenu]]></dc:creator>
		<pubDate>Mon, 12 Oct 2015 12:03:11 +0000</pubDate>
				<category><![CDATA[CodeProject]]></category>
		<category><![CDATA[JavaScript]]></category>
		<category><![CDATA[JQuery]]></category>
		<category><![CDATA[$ and $j as jquery]]></category>
		<category><![CDATA[jquery events]]></category>
		<category><![CDATA[jquery no-conflict]]></category>
		<category><![CDATA[Using Different Versions Of JQuery]]></category>
		<guid isPermaLink="false">http://sibeecst_passion.com/?p=10793</guid>

					<description><![CDATA[In this post we will see what is jQuery no-conflict and what is the importance of jQuery no-conflict. We will also learn how can we use different versions of JQuery in the same page according to your need. jQuery no-conflict is an option given by the jQuery to over come the conflicts between the different js frameworks or libraries. When we use jQuery no-conflict mode, we are replacing the $ to a new variable and assign to jQuery. Here in this post we will explain this feature in deep and we will also create a demo of using different versions [&#8230;]]]></description>
										<content:encoded><![CDATA[<p>In this post we will see what is jQuery no-conflict and what is the importance of jQuery no-conflict. We will also learn how can we use different versions of JQuery in the same page according to your need. jQuery no-conflict is an option given by the jQuery to over come the conflicts between the different js frameworks or libraries. When we use jQuery no-conflict mode, we are replacing the $ to a new variable and assign to jQuery. Here in this post we will explain this feature in deep and we will also create a demo of using different versions of jQuery together in one page. I hope you will like this. </p>
<p><strong>Download Source Code</strong></p>
<p>Please download the source code here: <a href="http://sibeeshpassion.com/wp-content/uploads/2015/10/jQueryNoConflict.rar" target="_blank">jQuery noConflict</a></p>
<p><strong>Introduction</strong></p>
<p>As you all know, some other JavaScript libraries also uses the $ (Which is the default reference of jQuery) as a function or variable name as jQuery has. And in our development life, we are not at all strict to only jQuery, we may use lots of other libraries too. Isn&#8217;t it? I use different libraries in my projects to accomplish different tasks. So what will happen when we use those libraries? There will be conflicts between those libraries right since they all use $ as the variable name. The situation is really bad.</p>
<p>So we have only one chocolate and more number of winners, in real life we can just cut the chocolate into the number of winners, right? </p>
<p><div id="attachment_10794" style="width: 644px" class="wp-caption alignnone"><a href="http://sibeeshpassion.com/wp-content/uploads/2015/10/Dogs-Sharing-Food-e1444646199502.jpg"><img decoding="async" aria-describedby="caption-attachment-10794" src="http://sibeeshpassion.com/wp-content/uploads/2015/10/Dogs-Sharing-Food-1024x768.jpg" alt="Dogs Sharing Food" width="634" height="476" class="size-large wp-image-10794" /></a><p id="caption-attachment-10794" class="wp-caption-text">Dogs Sharing Food</p></div></p>
<p>But that won&#8217;t be accepted in this case, so we have an another option, this option is introduced by jQuery and it is jQuery no-conflict. </p>
<p><strong>Background</strong></p>
<p>I always use different libraries in my project, thus sometimes I faced these problem in my project. So I thought of sharing with you all who are facing this problem.</p>
<p><strong>Using the code</strong></p>
<p>The first thing you want to do is creating an <a href="http://sibeeshpassion.com/category/html/" target="_blank">HTML </a>page.</p>
<p>[html]<br />
&lt;!DOCTYPE html&gt;<br />
&lt;html&gt;<br />
&lt;head&gt;<br />
    &lt;title&gt;JQuery noConflict &#8211; Sibeesh Passion&lt;/title&gt;<br />
&lt;/head&gt;<br />
&lt;body&gt;<br />
    JQuery noConflict &#8211; Sibeesh Passion<br />
&lt;/body&gt;<br />
&lt;/html&gt;<br />
[/html]</p>
<p>So what is next? Adding reference ? Yes.</p>
<p>[js]<br />
&lt;script src=&quot;prototype.js&quot;&gt;&lt;/script&gt;<br />
    &lt;script src=&quot;JQuery%20Versions/jquery-1.11.1.min.js&quot;&gt;&lt;/script&gt;<br />
[/js]</p>
<p>So we are using prototype lowest version and jquery together, in this case you will face conflict errors, and please be noted that the new version of prototype.js doesn&#8217;t have any conflict with jQuery since they updated and given the fix. </p>
<p>So what to do if you found any issues? you just need to give the $ to prototype and assign a new variable to jquery as follows.</p>
<p>[js]<br />
 &lt;script&gt;<br />
        // Give $ back to prototype.js; create new alias to jQuery.<br />
        var $jq = jQuery.noConflict();<br />
    &lt;/script&gt;<br />
[/js]</p>
<p>And now you can use $jq as the new jQuery reference.</p>
<p>[js]<br />
 &lt;script&gt;<br />
        $jq(document).ready(function () {<br />
            $jq(&quot;#btn&quot;).on(&#8216;click&#8217;, function () {<br />
                alert(&#8216;Clicked&#8217;);<br />
            });<br />
        });<br />
    &lt;/script&gt;<br />
[/js]</p>
<p><strong>Complete Code </strong></p>
<p>[html]<br />
&lt;!DOCTYPE html&gt;<br />
&lt;html&gt;<br />
&lt;head&gt;<br />
    &lt;title&gt;JQuery noConflict &#8211; Sibeesh Passion&lt;/title&gt;<br />
    &lt;script src=&quot;prototype.js&quot;&gt;&lt;/script&gt;<br />
    &lt;script src=&quot;JQuery%20Versions/jquery-1.11.1.min.js&quot;&gt;&lt;/script&gt;<br />
     &lt;script&gt;<br />
         // Give $ to prototype.js<br />
         var $jq = jQuery.noConflict();<br />
    &lt;/script&gt;<br />
    &lt;script&gt;<br />
        $jq(document).ready(function () {<br />
            $jq(&quot;#btn&quot;).on(&#8216;click&#8217;, function () {<br />
                alert(&#8216;Clicked&#8217;);<br />
            });<br />
        });<br />
    &lt;/script&gt;<br />
&lt;/head&gt;<br />
&lt;body&gt;<br />
    JQuery noConflict &#8211; Sibeesh Passion<br />
     &lt;br /&gt;<br />
    &lt;br /&gt;<br />
    &lt;br /&gt;<br />
     &lt;input type=&quot;button&quot; value=&quot;&quot; id=&#8217;btn&#8217; /&gt;<br />
&lt;/body&gt;<br />
&lt;/html&gt;<br />
[/html]</p>
<p>Sometimes we may end up in a situation to use different version of jQuery in the same page right? </p>
<p><strong>Situation I faced</strong></p>
<p>I was working in an old project which was handled by a team few years back, at that time I got a minor work to do in that project, to do the task I was in a need to add the latest version of jQuery since the entire project was using the old reference of jQuery. I was in a situation that I should not remove the old references and update with the new one, if I do that there might be some issues with other functionalities right? Since the project was already in live, I didn&#8217;t take that risk. So I added the new version and used jQuery noConflict to avoid the reference issues. </p>
<p><strong>Using the code</strong></p>
<p>Here I am going to give you a demo of now to use different version of jQuery in one page.</p>
<p>First of all please add the needed reference to your page.</p>
<p>[js]<br />
&lt;script src=&quot;JQuery%20Versions/jquery-1.9.0.min.js&quot;&gt;&lt;/script&gt;<br />
    &lt;script src=&quot;JQuery%20Versions/jquery-1.10.1.min.js&quot;&gt;&lt;/script&gt;<br />
    &lt;script src=&quot;JQuery%20Versions/jquery-1.11.0.min.js&quot;&gt;&lt;/script&gt;<br />
    &lt;script src=&quot;JQuery%20Versions/jquery-1.11.1.min.js&quot;&gt;&lt;/script&gt;<br />
    &lt;script src=&quot;JQuery%20Versions/jquery-1.11.3.min.js&quot;&gt;&lt;/script&gt;<br />
[/js]</p>
<p>Please be noted that we have added jQuery 1.9.0,1.10.1,1.11.0,1.11.1,1.11.3 in our page. </p>
<p>Now we need to add some buttons in the UI, later we will bind the click events of the same buttons. </p>
<p>[html]<br />
 &lt;input type=&quot;button&quot; value=&quot;Use jQuery 1.9.0&quot; id=&#8217;btn190&#8242; /&gt;<br />
    &lt;input type=&quot;button&quot; value=&quot;Use jQuery 1.10.1&quot; id=&#8217;btn1101&#8242; /&gt;<br />
    &lt;input type=&quot;button&quot; value=&quot;Use jQuery 1.11.0&quot; id=&#8217;btn1110&#8242; /&gt;<br />
    &lt;input type=&quot;button&quot; value=&quot;Use jQuery 1.11.1&quot; id=&#8217;btn1111&#8242; /&gt;<br />
    &lt;input type=&quot;button&quot; value=&quot;Use jQuery 1.11.3&quot; id=&#8217;btn1113&#8242; /&gt;<br />
[/html]</p>
<p>What is next, so we have added the different jQuery versions. Now we will create different variable names for each versions. Is that fine?</p>
<p>[js]<br />
 &lt;script src=&quot;JQuery%20Versions/jquery-1.9.0.min.js&quot;&gt;&lt;/script&gt;<br />
    &lt;script&gt;<br />
        var jQuery190 = jQuery.noConflict();<br />
        window.jQuery = jQuery190;<br />
    &lt;/script&gt;<br />
    &lt;script src=&quot;JQuery%20Versions/jquery-1.10.1.min.js&quot;&gt;&lt;/script&gt;<br />
    &lt;script&gt;<br />
        var jQuery1101 = jQuery.noConflict();<br />
        window.jQuery = jQuery1101;<br />
    &lt;/script&gt;<br />
    &lt;script src=&quot;JQuery%20Versions/jquery-1.11.0.min.js&quot;&gt;&lt;/script&gt;<br />
    &lt;script&gt;<br />
        var jQuery1110 = jQuery.noConflict();<br />
        window.jQuery = jQuery1110;<br />
    &lt;/script&gt;<br />
    &lt;script src=&quot;JQuery%20Versions/jquery-1.11.1.min.js&quot;&gt;&lt;/script&gt;<br />
    &lt;script&gt;<br />
        var jQuery1111 = jQuery.noConflict();<br />
        window.jQuery = jQuery1111;<br />
    &lt;/script&gt;<br />
    &lt;script src=&quot;JQuery%20Versions/jquery-1.11.3.min.js&quot;&gt;&lt;/script&gt;<br />
    &lt;script&gt;<br />
        var jQuery1113 = jQuery.noConflict();<br />
        window.jQuery = jQuery1113;<br />
    &lt;/script&gt;<br />
[/js]</p>
<p>So now we have added variable names for all the versions right? The next thing we are going to do is to fire the click events for each versions. </p>
<p>[js]<br />
 &lt;script&gt;<br />
        jQuery190(document).ready(function ($) {<br />
            //The codes for jQuery 1-9-0<br />
            $(&quot;#btn190&quot;).on(&#8216;click&#8217;, function () {<br />
                alert($.fn.jquery);<br />
            })<br />
        });<br />
        jQuery1101(document).ready(function ($) {<br />
            //The codes for jQuery 1-10-1<br />
            $(&quot;#btn1101&quot;).on(&#8216;click&#8217;, function () {<br />
                alert($.fn.jquery);<br />
            })<br />
        });<br />
        jQuery1110(document).ready(function ($) {<br />
            //The codes for jQuery 1-11-0<br />
            $(&quot;#btn1110&quot;).on(&#8216;click&#8217;, function () {<br />
                alert($.fn.jquery);<br />
            })<br />
        });<br />
        jQuery1111(document).ready(function ($) {<br />
            //The codes for jQuery 1-11-1<br />
            $(&quot;#btn1111&quot;).on(&#8216;click&#8217;, function () {<br />
                alert($.fn.jquery);<br />
            })<br />
        });<br />
        jQuery1113(document).ready(function ($) {<br />
            //The codes for jQuery 1-11-3<br />
            $(&quot;#btn1113&quot;).on(&#8216;click&#8217;, function () {<br />
                alert($.fn.jquery);<br />
            })<br />
        });<br />
    &lt;/script&gt;<br />
[/js]</p>
<p>So if you run your page and click the buttons, you can find that the related codes only get fired. </p>
<p><div id="attachment_10797" style="width: 655px" class="wp-caption alignnone"><a href="http://sibeeshpassion.com/wp-content/uploads/2015/10/jQuery_no-conflict_And_Using_Different_Versions_Of_JQuery.png"><img decoding="async" aria-describedby="caption-attachment-10797" src="http://sibeeshpassion.com/wp-content/uploads/2015/10/jQuery_no-conflict_And_Using_Different_Versions_Of_JQuery.png" alt="jQuery no-conflict And Using Different Versions Of JQuery" width="645" height="306" class="size-full wp-image-10797" srcset="/wp-content/uploads/2015/10/jQuery_no-conflict_And_Using_Different_Versions_Of_JQuery.png 645w, /wp-content/uploads/2015/10/jQuery_no-conflict_And_Using_Different_Versions_Of_JQuery-300x142.png 300w, /wp-content/uploads/2015/10/jQuery_no-conflict_And_Using_Different_Versions_Of_JQuery-400x190.png 400w" sizes="(max-width: 645px) 100vw, 645px" /></a><p id="caption-attachment-10797" class="wp-caption-text">jQuery no-conflict And Using Different Versions Of JQuery</p></div></p>
<p><div id="attachment_10798" style="width: 643px" class="wp-caption alignnone"><a href="http://sibeeshpassion.com/wp-content/uploads/2015/10/jQuery_no-conflict_And_Using_Different_Versions_Of_JQuery_1.png"><img decoding="async" aria-describedby="caption-attachment-10798" src="http://sibeeshpassion.com/wp-content/uploads/2015/10/jQuery_no-conflict_And_Using_Different_Versions_Of_JQuery_1.png" alt="jQuery no-conflict And Using Different Versions Of JQuery" width="633" height="312" class="size-full wp-image-10798" srcset="/wp-content/uploads/2015/10/jQuery_no-conflict_And_Using_Different_Versions_Of_JQuery_1.png 633w, /wp-content/uploads/2015/10/jQuery_no-conflict_And_Using_Different_Versions_Of_JQuery_1-300x148.png 300w, /wp-content/uploads/2015/10/jQuery_no-conflict_And_Using_Different_Versions_Of_JQuery_1-400x197.png 400w" sizes="(max-width: 633px) 100vw, 633px" /></a><p id="caption-attachment-10798" class="wp-caption-text">jQuery no-conflict And Using Different Versions Of JQuery</p></div></p>
<p>Now what if you comment out the variable declaration for jQuery version 1.11.3? </p>
<p>[js]<br />
//var jQuery1113 = jQuery.noConflict();<br />
        //window.jQuery = jQuery1113;<br />
[/js]</p>
<p>You will get an error says <em>Uncaught ReferenceError: jQuery1113 is not defined</em> in browser console. </p>
<p><div id="attachment_10799" style="width: 647px" class="wp-caption alignnone"><a href="http://sibeeshpassion.com/wp-content/uploads/2015/10/jQuery_no-conflict_And_Using_Different_Versions_Of_JQuery_2.png"><img decoding="async" aria-describedby="caption-attachment-10799" src="http://sibeeshpassion.com/wp-content/uploads/2015/10/jQuery_no-conflict_And_Using_Different_Versions_Of_JQuery_2.png" alt="jQuery no-conflict And Using Different Versions Of JQuery" width="637" height="336" class="size-full wp-image-10799" srcset="/wp-content/uploads/2015/10/jQuery_no-conflict_And_Using_Different_Versions_Of_JQuery_2.png 637w, /wp-content/uploads/2015/10/jQuery_no-conflict_And_Using_Different_Versions_Of_JQuery_2-300x158.png 300w, /wp-content/uploads/2015/10/jQuery_no-conflict_And_Using_Different_Versions_Of_JQuery_2-600x315.png 600w, /wp-content/uploads/2015/10/jQuery_no-conflict_And_Using_Different_Versions_Of_JQuery_2-400x211.png 400w" sizes="(max-width: 637px) 100vw, 637px" /></a><p id="caption-attachment-10799" class="wp-caption-text">jQuery no-conflict And Using Different Versions Of JQuery</p></div></p>
<p><strong>Complete Code</strong></p>
<p>[html]<br />
&lt;!DOCTYPE html&gt;<br />
&lt;html&gt;<br />
&lt;head&gt;<br />
    &lt;title&gt;Use JQuery Different Versions in One Page &#8211; Sibeesh Passion&lt;/title&gt;</p>
<p>    &lt;script src=&quot;JQuery%20Versions/jquery-1.9.0.min.js&quot;&gt;&lt;/script&gt;<br />
    &lt;script&gt;<br />
        var jQuery190 = jQuery.noConflict();<br />
        window.jQuery = jQuery190;<br />
    &lt;/script&gt;<br />
    &lt;script src=&quot;JQuery%20Versions/jquery-1.10.1.min.js&quot;&gt;&lt;/script&gt;<br />
    &lt;script&gt;<br />
        var jQuery1101 = jQuery.noConflict();<br />
        window.jQuery = jQuery1101;<br />
    &lt;/script&gt;<br />
    &lt;script src=&quot;JQuery%20Versions/jquery-1.11.0.min.js&quot;&gt;&lt;/script&gt;<br />
    &lt;script&gt;<br />
        var jQuery1110 = jQuery.noConflict();<br />
        window.jQuery = jQuery1110;<br />
    &lt;/script&gt;<br />
    &lt;script src=&quot;JQuery%20Versions/jquery-1.11.1.min.js&quot;&gt;&lt;/script&gt;<br />
    &lt;script&gt;<br />
        var jQuery1111 = jQuery.noConflict();<br />
        window.jQuery = jQuery1111;<br />
    &lt;/script&gt;<br />
    &lt;script src=&quot;JQuery%20Versions/jquery-1.11.3.min.js&quot;&gt;&lt;/script&gt;<br />
    &lt;script&gt;<br />
        //var jQuery1113 = jQuery.noConflict();<br />
        //window.jQuery = jQuery1113;<br />
    &lt;/script&gt;<br />
    &lt;script&gt;<br />
        jQuery190(document).ready(function ($) {<br />
            //The codes for jQuery 1-9-0<br />
            $(&quot;#btn190&quot;).on(&#8216;click&#8217;, function () {<br />
                alert($.fn.jquery);<br />
            })<br />
        });<br />
        jQuery1101(document).ready(function ($) {<br />
            //The codes for jQuery 1-10-1<br />
            $(&quot;#btn1101&quot;).on(&#8216;click&#8217;, function () {<br />
                alert($.fn.jquery);<br />
            })<br />
        });<br />
        jQuery1110(document).ready(function ($) {<br />
            //The codes for jQuery 1-11-0<br />
            $(&quot;#btn1110&quot;).on(&#8216;click&#8217;, function () {<br />
                alert($.fn.jquery);<br />
            })<br />
        });<br />
        jQuery1111(document).ready(function ($) {<br />
            //The codes for jQuery 1-11-1<br />
            $(&quot;#btn1111&quot;).on(&#8216;click&#8217;, function () {<br />
                alert($.fn.jquery);<br />
            })<br />
        });<br />
        jQuery1113(document).ready(function ($) {<br />
            //The codes for jQuery 1-11-3<br />
            $(&quot;#btn1113&quot;).on(&#8216;click&#8217;, function () {<br />
                alert($.fn.jquery);<br />
            })<br />
        });<br />
    &lt;/script&gt;<br />
&lt;/head&gt;<br />
&lt;body&gt;<br />
    Use JQuery Different Versions in One Page<br />
    &lt;br /&gt;<br />
    &lt;br /&gt;<br />
    &lt;br /&gt;<br />
    &lt;input type=&quot;button&quot; value=&quot;Use jQuery 1.9.0&quot; id=&#8217;btn190&#8242; /&gt;<br />
    &lt;input type=&quot;button&quot; value=&quot;Use jQuery 1.10.1&quot; id=&#8217;btn1101&#8242; /&gt;<br />
    &lt;input type=&quot;button&quot; value=&quot;Use jQuery 1.11.0&quot; id=&#8217;btn1110&#8242; /&gt;<br />
    &lt;input type=&quot;button&quot; value=&quot;Use jQuery 1.11.1&quot; id=&#8217;btn1111&#8242; /&gt;<br />
    &lt;input type=&quot;button&quot; value=&quot;Use jQuery 1.11.3&quot; id=&#8217;btn1113&#8242; /&gt;<br />
&lt;/body&gt;<br />
&lt;/html&gt;<br />
[/html]</p>
<p>That&#8217;s all.</p>
<p><strong>Conclusion</strong></p>
<p>Did I miss anything that you may think which is needed? Have you ever used different versions of jQuery in same page? Have you ever tried jQuery noConflict? Could you find this post as useful? I hope you liked this article. Please share me your valuable suggestions and feedback.</p>
<p><strong>Your turn. What do you think?</strong></p>
<p>A blog isn’t a blog without comments, but do try to stay on topic. If you have a question unrelated to this post, you’re better off posting it on C# Corner, Code Project, Stack Overflow, Asp.Net Forum instead of commenting here. Tweet or email me a link to your question there and I’ll definitely try to help if I can.</p>
<p>Kindest Regards<br />
Sibeesh Venu</p>
]]></content:encoded>
					
					<wfw:commentRss>https://mail.sibeeshpassion.com/jquery-no-conflict-and-using-different-versions-of-jquery/feed/</wfw:commentRss>
			<slash:comments>4</slash:comments>
		
		
			</item>
	</channel>
</rss>
