Cristian Salcescu's Blog, page 7
June 30, 2021
How to Pass Arguments to setTimeout and setInterval Callbacks
Use the additional arguments when calling the timer functions
June 29, 2021
3 Ways to Conditionally Invoke a Callback
The if statement, the And operator, and the optional chaining operator
June 28, 2021
How to Handle the JSON Conversion in a Factory Function
How to Convert Sets into Arrays
June 24, 2021
How to Conditionally Invoke a Method
The And operator, the optional chaining method calls operator, and more
June 23, 2021
How to Find Elements in Large Arrays
Quick start with filter and find. Improve search speed by creating and using maps.
June 21, 2021
How to Store and Retrieve Objects From the Local and Session Storage
JSON.stringify, JSON.parse utilities, setItem and getItem store methods and more
Interesting Things to Know About The toString and valueOf Methods
Quick start with converting objects into primitives in JavaScript
All Objects are Truthy Values
All Objects are Truthy Values
Converting any object into a boolean gives the true value. Here are a few examples.
Boolean({}) //trueBoolean([]) //true
Boolean(new Date()) //true
Even the wrapper object for the false value returns true.
const falseWrapper = new Boolean(false);Boolean(falseWrapper); //true
All objects are considered to be truthy values. They are evaluated to true in a test condition.
if({}){console.log('Truthy');
}else {
console.log('Falsy');
}
//'Truthy'
Negating an object using the Not (!...
June 16, 2021
How To Convert Between Primitives in JavaScript
Get up to speed with the Number, String, and Boolean functions