day 11 ,12 of 1000 days
Welcome to my blog.
Js:- I revised the topics I have covered. For that I am using eloquent js book, its pdf is available at their site. I will mention all of them in brief. In js we have expressions, which are code that gives some value and statements which don't give some value. The value in general terms is a packet of data. We use variable names to store or points to values. Remember in js value has type not variable. In js value can be of two types primitive and object. Primitive is further divided into numbers, strings, boolean, null and undefined. Number is used to represent integers and decimal(float) values. There are some special numbers like infinity, -infinity, and NaN. It's better to avoid them in calculations as they give weird results. NaN is generated when numeric operations don't give meaningful results. Also typeof NaN ===NaN gives false. typeof is used to check type of value a variable has. For strings, js use unicode 16 to represent them internally. I am not sure but it means 16 bits to store a character. But as unicode has more characters some are assigned twice space like emoji. We use .length to check the number of characters in a string(it's not base 0). Boolean is true or false. Null and undefined are confusing, I will have to search more about them.
Control flow- normally in js code executes from top to bottom. By using some statements and expressions we can change the flow to our advantage. if-else, switch-case, loops and functions are used to control the flow. In loop, we use break, which ends the loop and move out, and continue, which ends the current iteration & starts the next iteration. Function is a program or code wrapped in a variable. If it returns a value it becomes expression. If a function does something else other than returning a value (even printing console.log), it's called side effect. It sounds negative, but I don't know more than this about it. In operators I learned short-circuiting, which has simple logic. Just remember 0, "", NaN =false. Or(||) will return the true as soon as it finds or the last value. And(&&) will return false if it finds it or the last value. There is a ternary operator, it can be used in place of if-else statement as it's an expression. Condition? do1 : do2, if condition is true do1 will execute else do2 will execute. For calculation js follows bodmas, though using () seems better as option to avoid confusion, prettier removes the unwanted automatically. There is variable++ and ++variable increment(inc by 1). vari++ will use the variable value in the expression and then increment it, ++vari will first increment it then use the inc value. We have Number object which has method to test is a variable NaN or not. Number.isNaN(v), it will return true if v is NaN.
Rest I practised my js skills on codewar.
Personal: Sorry for not being regular, had much going on in my personal life. First I was ill then an unfortunate event happened due to which I got busy. But good thing is that all personal work is over now and I am free to continue my coding journey.