[{"id":"recUogJixEBGNoCUm","fields":{"explain":"The code above returns true. Yes hell! \"NaN\" in the right \"baNaNa\" simply means \"Not a number\". \n\nNote that in JS, the plus sign (+) can be used as an operator (for number) and for concatenating (for string).","number":1,"post__type":"tip","Notes":"` \"b\" + \"a\" + + \"a\" + \"a\" === \"baNaNa\"<\/code>\n"},"createdTime":"2021-08-01T11:22:03.000Z"},{"id":"recOy2pURxo92cwGe","fields":{"explain":"Given the fact that we can re-declare a variable if it has been initially declared with \"var\".\n\nSay, \n\nvar x = 10; \nvar x = 12; \nconsole.log(x) \/\/12 <\/strong>\n<\/code>\n\nIt is therefore highly recommended not to use \"var\" in any case.\n","number":2,"post__type":"info","Notes":"variable without any functional word in the beginning is terribly bad and \"var\" keyword is also \nunfortunately terrible.\n"},"createdTime":"2021-08-01T10:19:26.000Z"},{"id":"rec2tHHu5BEoqfkJO","fields":{"explain":"So technically there are four ways to declare a variable: \n\n1) no keyword, \n2) var (not recommended), \n3) const (highly recommended)\n4) let (when you want to change the value)","number":3,"post__type":"info","Notes":"you can even declare a variable without any functional keyword such as \"var\", \"let\", or \"const\".\n"},"createdTime":"2021-08-01T10:19:26.000Z"},{"id":"recDw02foDSkTqoDK","fields":{"explain":"Let write some more code: \nconsole.log(typeof null), \/\/ \"object\".<\/strong>\n\n console.log(typeof undefined) \/\/ \"undefined\".<\/strong>\n<\/code>\n\nOMG, \n\nconsole.log(null instanceof Object); \/\/ false<\/strong>\n","number":4,"post__type":"info","Notes":" null is an object, \"but\"\n"},"createdTime":"2021-08-01T10:19:26.000Z"},{"id":"recWiuek1cCkPCK89","fields":{"explain":"It is said that array is a sub-type of object in JS. So the code above returns \"object\". \nFYI: \nconsole.log(typeof {})\/\/ \"object\" <\/code>\nHow to fix that? Go with Array.isArray(isObjectorArray) <\/code>","number":5,"post__type":"tip","Notes":"console.log(typeof []) \/\/object <\/strong> <\/code>\n"},"createdTime":"2021-08-01T10:42:00.000Z"},{"id":"reclV1ZrRyegP4ew1","fields":{"explain":"NaN means \"Not a number\" but its typeof is \"number\". Go crazy!!!","number":6,"post__type":"info","Notes":"\nconsole.log(typeof NaN)\/\/\"number\"\n<\/code>\n"},"createdTime":"2021-08-01T10:53:35.000Z"},{"id":"recuf6W92wao6YCS6","fields":{"explain":"The code returns false. So I have nothing to say, just memorize it and avoid any particular bugs caused by.\n","number":7,"post__type":"tip","Notes":"console.log(NaN === NaN); \/\/false<\/strong><\/code>\n"},"createdTime":"2021-08-01T10:54:30.000Z"},{"id":"recglvdYhCbVtXwwP","fields":{"explain":"This one is very famous and the cause rooted in the floating-point math which you might find in any other programming languages, one way or another. \n\nSo you should not blame JavaScript for this one.","number":8,"post__type":"info","Notes":"0.1 + 0.2; \/\/ -> 0.30000000000000004<\/strong> \n0.1 + 0.2 === 0.3; \/\/ -> false<\/strong>\n<\/code>\n"},"createdTime":"2021-08-01T14:38:18.000Z"},{"id":"rechVSp34Ad3ZFw6m","fields":{"explain":"The constant gives us the value 5e-324, i.e. the smallest positive number that can be represented within float precision, i.e. that's as close as you can get to zero. It defines the best resolution floats give you. ","number":9,"post__type":"tip","Notes":"Number.MIN\\_VALUE > 0; \/\/ -> true<\/strong><\/code>\n"},"createdTime":"2021-08-01T16:48:02.000Z"},{"id":"rec8okvDONO5T6SSb","fields":{"explain":"Math.min(number1, number2) and Math.max(number1, number2) allow us to find the smallest and the largest number in a collection, let say. \n\nBut if we do not pass any parameter into the function then by default Math.min(); \/\/ -> Infinity and Math.max(); \/\/ -> -Infinity.","number":10,"post__type":"info","Notes":"\nMath.max() < Math.min() \/\/true<\/strong>\n<\/code>\n"},"createdTime":"2021-08-02T05:56:30.000Z"},{"id":"recGzkpt6u1mBUAUq","fields":{"explain":"silence is golden\n","number":11,"post__type":"info","Notes":"\nconsole.log(null ==0); \/\/false<\/strong> \nconsole.log(null ===0); \/\/false <\/strong>\nconsole.log(null >0); \/\/false<\/strong> \nconsole.log(null >=0); \/\/true<\/strong> \n<\/code>\n"},"createdTime":"2021-08-02T07:47:21.000Z"},{"id":"reci6eOYQcmZZAVtb","fields":{"explain":"\"1,2,34,5,6\". When the plus sign (+) is used with two different features\/functions in a single context.","number":12,"post__type":"info","Notes":"[1, 2, 3] + [4, 5, 6]<\/code>\n"},"createdTime":"2021-08-02T08:07:08.000Z"},{"id":"recQLjwi4HSFzSVcc","fields":{"explain":"You might see that the operator == only compares the value while === takes both value and type into consideration. \n\nIf you write \"10\" == 10, then we get true but \"10\" === 10 returns false. \nconsole.log(\"10\" == 10)\/\/true<\/strong>\nconsole.log(\"10\" === 10)\/\/false<\/strong>\n<\/code>","number":13,"post__type":"tip","Notes":"console.log([] == 0) \/\/true<\/strong>\n<\/code>\nBUT \n\nconsole.log([] === 0) \/\/false<\/strong>\n<\/code>\n"},"createdTime":"2021-08-12T14:27:08.000Z"},{"id":"recoW9RDahHI30Pcx","fields":{"explain":"Both return true. \nBut console.log(true === 1)\/\/ false<\/strong><\/code> because here both type and value are taken into account.","number":14,"post__type":"info","Notes":"\nconsole.log(true + true === 2); \/\/true<\/strong>\nconsole.log(true - true === 0); \/\/true<\/strong>\n<\/code>\n"},"createdTime":"2021-08-12T14:31:30.000Z"},{"id":"recY7Pu9BFIqBlFdR","fields":{"explain":"This is not a bug. Using the default JavaScript sort() method converts the elements of arrays into strings. \n\nIt then compares the UTF-16 values and sorts the list based on these UTF-16 values.\n\nYou might note that the list sorted according to the first digit, so 13 is less than 9 because 1 < 9.","number":15,"post__type":"tip","Notes":"\nlet collections = [9, 13, 3, 20, 49, 10];\n\nconsole.log(collections.sort()) \/\/[10, 13, 20, 3, 49, 9]<\/strong>\n<\/code>\n"},"createdTime":"2021-08-13T03:36:06.000Z"},{"id":"recyEHYCwJ8XRco7y","fields":{"explain":"As 1 < 2 <\/code> returns true<\/strong> and so true < 3 <\/code>also returns true<\/strong>.\n\nOn the second line, 3> 2 <\/code> return true<\/strong>, but true > 1<\/code> gives us false<\/strong>.","number":16,"post__type":"info","Notes":"\n1 < 2 < 3; \/\/ -> true<\/strong>\n\n3 > 2 > 1; \/\/ -> false<\/strong>\n<\/code>\n"},"createdTime":"2021-08-13T04:17:16.000Z"},{"id":"rec8NLc0n4yA73xMm","fields":{"explain":"Note that Math.max() is not the same thing as Number.MAX_VALUE. And hence, as you might see, the following code returns true: \n\n Math.min() > Math.max(); \/\/true<\/strong>\n<\/code>","number":17,"post__type":"tip","Notes":"Math.min(); \/\/ -> Infinity \nMath.max(); \/\/ -> -Infinity \nInfinity > -Infinity; \/\/ -> true \n<\/code>\n\n"},"createdTime":"2021-08-13T11:36:01.000Z"},{"id":"recCMz1uGYbcDGLdP","fields":{"explain":"The long story short: There is no \"class\" in JavaScript if you use \"typeof\" operator. But who cares?","number":18,"post__type":"info","Notes":"\nclass a {\u00a0}\n\nconsole.log(typeof a) \/\/ \"function\" <\/strong>\nfunction b(){}\n\nconsole.log(typeof b) \/\/\"function\"<\/strong>\n\n\n<\/code>\n"},"createdTime":"2021-08-14T10:10:53.000Z"},{"id":"recRrWfskKHEgU4DX","fields":{"explain":"callback will only be triggered AFTER all synchronous code has been executed, no matter how many mini-second you set here.","number":19,"post__type":"info","Notes":"\nsetTimeout(callback, 0)\n<\/code>\n"},"createdTime":"2021-08-14T10:26:05.000Z"},{"id":"recNtdF35WsehzeWy","fields":{"explain":"\nconsole.log(Array.isArray(a)) \/\/ true <\/strong>\nconsole.log(Array.isArray(b)) \/\/true<\/strong>\n<\/code>\n\n\nThe first way is not recommended.\n","number":20,"post__type":"info","Notes":"\nconst a = new Array(); \nconsole.log(typeof a) \/\/\"object\"<\/strong>\nconst b = []; \nconsole.log(typeof b) \/\/\"object\"<\/strong>\n<\/code>\n"},"createdTime":"2021-08-14T10:34:28.000Z"},{"id":"recgn9yzNktXU1ELV","fields":{"explain":"You can convert an array to object using ...rest operator. The output will be : \n\n\n\n [object Object] {\n 0: \"hello\",\n 1: \"World\"\n }\n<\/code>\n","number":21,"post__type":"tip","Notes":"\nconst array = [\"hello\", \"World\"];\n\nconsole.log({...array})\n<\/code>\n"},"createdTime":"2021-08-18T05:49:27.000Z"}]`