Good stuff guys! I'm working through all your videos and finding it very helpful. I appreciate the insights as to why something should or should not be done.
The double/triple equals (and related !) operators deserve a little more clarification. +Eric Andre is correct, the difference is that === (strict equal) and !== (strict not equal) take into account the type of the values. Douglas Crockford (and Jared) advocate that you always use the strict variants to help eliminate possible unexpected behavior. In Jared's code, you're likely to see something like this: var a = "4"; if (parseInt(a, 10) === 4) just to be safe.
Isn't the difference between == and === mostly to do with type? Maybe something like. var a = 4; if (a == "4") { // true } if (a === "4" { // false } I think it may be a little more complex, but basically it comes down to it has to be the same type?
The thing I have trouble with is remembering all of the different types of javascript premade functions or methods, I wonder how y'all remember them in your everyday jobs, or is it you have used them so much it is second nature.
Some of them I manage to remember (the once I use most frequently). Still, I've pretty much always got at least one MDN tab open in my browser. These days being "smart" isn't so much about knowing stuff, but knowing how to find stuff.
+Source Decoded That's actually very similar to what Henry Ford (the founder of Ford) is said to have stated while on the witness stand in a court case long long ago. (The full story is in the book *Think and Grow Rich* I believe.)
21:51 Hang on a minute! The purpose of *var yes = a && true;* is not clear at all, because the function calls still return true and false respectively without that line. Plus, the variable (yes) is unused. EDIT: Nevermind. I tinkered with the code a bit: var myFunc = function(a) { var yes = a && true; console.log(yes); }; myFunc(2 == 2); // this logs "true" to the console myFunc(5 == 7); // while this logs "false"
i still dont get the diference berween === and == in javascript I always use == because that is how i learned it. Here is a question: In javaEclipse you use System.out.print("something"); to print something to the console, but you use console.log("something"); Whats the difference because they are bouth java. Another question is: Why do you use var? in the eclipse environment you have to define what type of variable you're going to use like: int c=4; String greeting="hi"; boolean alive=true; whats the difference
("12" == 12) results in true. ("12" === 12) results in false. The double equals is lazy, imprecise. If a number and a string "look" the same, it'll say they are the same. The triple equals is strict. A number 12 and a string "12" might look the same, but they are different types (number and string), so === will say they are different. === is the "equivalency" operator, meaning the two values have to actually be exactly the same (in type and value). Hope that helps.
Dj Ace74 The difference between === and == has to do with coercion. E.g '2' == 2 evaluates to true, because the syntax parser in the execution environment thinks it's supposed to be a variable, cos '2' is a variable while 2 is a number/integer. If you really want 2 in the above example and not '2', then you use '2' === 2 which means strongly, important or whatever you wana call it. Hence the above will execute to false. This can really save you hours of debugging, when shit suddenly hits the fan.
Dj Ace74 Java and Javascript are two completely different languages Javascript is a dynamic language meaning you don't need to specify types etc like string or number it will automatically assign data types for you. Console. log uses a print command under the hood.
+The gamer It is a function that means "log" or write what the statement gets equated to inside of the console. The console can be seen by running Chrome developer tools for example. Cmd + option + j on a Mac. So if you declare a variable for example: var a = 8 and then run the function with the variable as an argument - what goes inside the brackets... console.log(a) In the console you will see the result '8'
Difference between a double == and triple === are. == Equal value === Equal value and Equal Type. What does that mean? Well, let me show you. Let's compare 12 with 12 and "12" with 12. Numbers inside Quotes " " are designated as STRING TYPE. Numbers without Quotes are simply just number types. So. 12 == 12 True "12" == 12 True as well. Because the Double == compares only the values not their types. But 12 === 12 True "12" === 12 False. Although the values are true, the data types aren't, thus a False output.
I don't understand how you can waste 15 min explaining basic math operators but you skip over === and a++ , a+=1 .... this stuff is used on a daily basis and they are very handy shortcuts. This video is very weak compared to the others. All the basics can be easily covered in 5 min, just telling people "go look it up" on all the hard stuff removes the need to watch this video....