Wise man or Wise guy? You Decide

Just another WordPress.com weblog

Learning some javascript

Posted by sqlwiseguy on July 24, 2009

As part of my work I need to be a “Jack of all trades” meaning I not only need to be able to do SQL Server DBA and development tasks, but I also need to be capable of doing .NET and VFP development.  Yes, I did say VFP (Visual FoxPro for those who are too young to know what it is). 

The major project in which I am involved is using SQL Server and ASP.NET (C#) MVC.  Fortunately I had downloaded Scott Guthrie’s NerdDinner tutorial when it first came out and have just finished going through it.  In the tutorial I came across some code like this:

if (item.Description !== undefined) {
description = item.Description;
}

Well, I had never seen the !== operator before and assumed that it was a typo and was supposed to be:

if (item.Description != undefined) {
description = item.Description;
}

since I know that == the equality comparison operator and != is the inequality comparison operator.  Well, then I found the same operator later in the code, so I thought, “Hmmm, maybe this isn’t a typo, but a real operator?”, so off to www.google-vs-bing.com to see what I could find.  Well, I didn’t find anything helpful on page 1 of either search engine’s results.  Next a quick question on Twitter.  Ahhh, several replies that, “Yes !== and === are operators and they compare type AND value”.  Having always programmed in strongly typed languages this is new and interesting to me.  So basically in javascript 1 == “1” is true, but 1 === “1” is false.

I still would rather be in SQL, but at least now I am starting to understand more about javascript.

Advertisements

One Response to “Learning some javascript”

  1. Frank said

    I find the hard thing about getting my head around programming languages is the feeling that I'm a goldfish because I've had to teach myself the same thing so many times!

    I've lost count of the number of occasions when I've had a project for which I've had to learn javascript only to need it again 6 months later and have to teach myself the document object model again. The same goes for PHP, C#, and VBA. Thankfully SQL remains a constant throughout!

    On the subject of your post, this operator is used in PHP too. And PHP is a C based language I think so there are probably a few more languages that use these operands too. Here's what the manual describes them as…

    = Assignment
    == Equivalent
    === Identical

    Cheers
    Frank

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

 
%d bloggers like this: