Table Of Contents
* ✅BOOLEAN VALUES
* 💡LOGICAL OPERATOR
* ❓TERNARY OPERATOR
* EMPTY VALUES
* 🦾AUTOMATIC TYPE CONVERSION
* ➕APPENDIX 1
* 🙏THANK YOU
Values of the number are numeric values (like we didn't know that 😂). When you type up the number in your program, it will cause the bit pattern for that specific number to come into existence inside the computer's memory.
➗ THE MATHS BEHIND IT
So, the actual maximum whole number that can be stored is more in the range of the 9 quadrillions (15 zeros) - which is pretty huge!
Calculations with whole numbers (also called integers) smaller than the aforementioned 9 quadrillions are guaranteed to always be precise. Unfortunately, calculations with fractional numbers are generally not.
The main thing to do with numbers is arithmetic. Arithmetic operations, like addition or multiplication, take two number values and produce a new number from them. For example:
11 + 213 * 11
The + and * symbols are called operators. The first stands for addition and the second stands for multiplication. Putting an operator between two values will apply it to those number values and will produce a new number value. The multiplication like in a real-world maths comes first! The subtraction comes with a - sign.
If operators appear together without parentheses, the order in which they are applied is determined by the precedence of the operators.
The * and / have the same precedence. Likewise for + and - operators. If there are multiple operators with the same precedence, they are applied left to right.
There is one more important arithmetic operation. The remainder operation, denoted with a symbol %. X%Y is the remainder of dividing X by Y.
As we mentioned yesterday, strings are used to represent text. They are written by enclosing their content in quotes:
var double_quotes = "Coding is fun!"; var single_quote = 'Coding is fun!'; var backticks = `Coding is fun!`;
Let's see an example:
var newline_string = 'Coding \n is fun!'; console.log(newline_string) /* OUTPUT: Coding is fun!*/
There are situations where you want a backslash in a string to be just a backslash, not a special code. If two backslashes follow each other, they will collapse together.
var collapse = "Coding \"\\n\" is fun." console.log(collapse) /* OUTPUT: Coding "\n" is fun. */
Strings cannot be divided, multiplied, or substructed, but the + operator can be used on them to concatenate them.
var concat = "Coding" + "is" + "fun!"; console.log(concat); /* OUTPUT: Codingisfun! */
✅ BOOLEAN VALUES
var boolean_value = true; //this is a boolean value var string_value = "true"; //this is a string value
Let's use it in a real example.
console.log(3 > 2); //output: true console.log(3 < 2); //output: false
💡 LOGICAL OPERATORS
console.log(true && false); // output: false console.log(true && true); // output: true console.log(true || false); // output: true console.log(true || true); //output: true console.log(false || false); //output: false
❓ TERNARY OPERATOR
A conditional operator (or sometimes called the ternary operator since it is the only such operator in the language). The value on the left of the question mark "picks" which of the other two values will come out. When it is true, it chooses the middle value, and when it is false, it chooses the value on the right.
console.log(true ? 1 : 2); // output: 1 console.log(false ? 1 : 2); // output: 2
There are two special values, written null and undefined, that are used to denote the absence of a meaningful value. They are themselves values, but they carry no information.
Many operations in the language that don’t produce a meaningful value yield undefined simply because they have to yield some value.
🦾 AUTOMATIC TYPE CONVERSION
console.log(10 * null); //output: 0 console.log("5" - 1); //output: 4 console.log("5" + 1); //output: 51 console.log("five" * 2); //NaN console.log(false == 0); //true
- Values of the number are numeric values
- If you had N decimal digits, you can represent ten to the power of N numbers - 10N
- Putting an operator between two values will apply it to those number values and will produce a new number value.
- If operators appear together without parentheses, the order in which they are applied is determined by the precedence of the operators.
- Strings cannot be divided, multiplied, or substructed, but the + operator can be used on them to concatenate them
- Many operations in the language that don’t produce a meaningful value yield undefined simply because they have to yield some value.
➕APPENDIX 1 - LOGICAL OPERATORS VISUAL REPRESENTATION
From an image we conclude:
- OR is true whenever is X or Y true
- Exclusive OR is true only when X is true or the Y is true
- AND is true only when X is true and Y is also true
🙏 THANK YOU FOR READING!
Please leave the comment, tell me about you, about your work, comment your thoughts, connect with me!
☕ SUPPORT ME AND KEEP ME FOCUSED!
Have a nice time hacking! 😊
Top comments (3)
Thank you, Kunal! 🚀