Search
 
SCRIPT & CODE EXAMPLE
 

JAVASCRIPT

javascript Implicit Boolean Conversion to Number

// if boolean is used, true is 1, false is 0

let result;

result = '4' - true;
console.log(result); // 3

result = 4 + true;
console.log(result); // 5

result = 4 + false;
console.log(result); // 4
Comment

PREVIOUS NEXT
Code Example
Javascript :: what f a number exceeding 2^53 in javascript 
Javascript :: ternary operator multiple conditions 
Javascript :: ring add an attribute to the object 
Javascript :: JavaScript Methods and this Keyword 
Javascript :: javascript Remove Element from Inner Array 
Javascript :: javascript Symbol Properties 
Javascript :: javascript Multiline Strings Using Template Literals 
Javascript :: javascript Skip Items 
Javascript :: js tilda 
Javascript :: can i copy package-lock.json to another project 
Javascript :: JavaScript Validation API 
Javascript :: httpclient post raw json body 
Javascript :: GetAsync() with a dateime 
Javascript :: javascript process.env.key with  
Javascript :: How to Update the Props of a Rendered Component in vue Testing Library 
Javascript :: flip image on y axis phaser 
Javascript :: phaser place on line 
Javascript :: phaser hide animation on complete 
Javascript :: iterate cy.get(') elements 
Javascript :: npm deploy next js with tailwind 
Javascript :: nodejs stream pipeline 
Javascript :: how to target a hidden html element by js 
Javascript :: how to run javascript in terminal 
Javascript :: how to declare a variable js 
Javascript :: javascript add to a dictionary 
Javascript :: what is local storage and session storage in javascript 
Javascript :: javascript add onclick to multiple elements 
Javascript :: in javascript pass infinite argument in function 
Javascript :: age calculator moment js 
Javascript :: react-hook-form-input npm 
ADD CONTENT
Topic
Content
Source link
Name
3+6 =