- OBJECTS
- Basics
- Reference
- Methods
- Constructor
- FUNDAMENTALS
- Hello World
- Code Structure
- Use Strict
- Variables
- Data Types
-
Type Conversions
- Maths
- Comparitions
- Conditional
- Loops
- Functions
- TESTING
- Mocha
- Nested Describe
- TYPES
- Primitives
- Numbers
- Strings
- Arrays
- Json
- DESIGN PATTERN
- Observer Pattern
- CLASSES
- Constructor
- Binding
- Inheritance
Numeric
Most of the time Javascript automatically converts to the right type.
/**
* Mathematical functions and expressions ...
* strings are automatically converted to numbers.
*
* The addition operator (+) doesn't convert strings to numbers.
*/
console.log("2" + "3"); // 23, not 5
console.log("6" / "3"); // 2
console.log(Number("2") + Number("3")); // 5
console.log(String(2) + String(3)); // 23 - Look Here
Questions and answers
Math expression that does automatic conversion?
- a) "1" + "2"
- b) "6" / "2"
Boolean by "0" is true in:
- a) Javascript
- b) PHP