Search
 
SCRIPT & CODE EXAMPLE
 

JAVASCRIPT

plus sign javascript

// JavaScript Unary Operators The unary plus operator (+)
// The unary plus ( + ) precedes its operand and evaluates to its operand. It attempts to convert the operand to a number, if it isn't already.

+42           // 42
+"42"         // 42
+true         // 1
+false        // 0
+null         // 0
+undefined    // NaN
+NaN          // NaN
+"foo"        // NaN
+{}           // NaN
+function(){} // NaN

// Note that attempting to convert an array can result in unexpected return values.
// In the background, arrays are first converted to their string representations:

[].toString() === '';
[5].toString() === '5';
[1, 2].toString() === '1,2';

// The operator then attempts to convert those strings to numbers:

+[]           // 0   ( === +'' )
+[5]          // 5   ( === +'5' )
+[1, 2]       // NaN ( === +'1,2' )
Comment

PREVIOUS NEXT
Code Example
Javascript :: plus operator javascript 
Javascript :: javascript static 
Javascript :: return the sum of an array 
Javascript :: best method to convert string to upper case manually 
Javascript :: javascript spread syntax 
Javascript :: var 
Javascript :: how can i use exact in react router dom v6 
Javascript :: javascript join 2 variables into string 
Javascript :: switch statement 
Javascript :: nodejs cluster 
Javascript :: Child nodes in a node 
Javascript :: express multer 
Javascript :: make button disabled if input is empty angular 
Javascript :: trim function 
Javascript :: async vs await javascript 
Javascript :: setimmediate javascript 
Javascript :: append css file with javascript 
Javascript :: js classlist multiple classes 
Javascript :: Plugin "react" was conflicted between "package.json » eslint-config-react-app 
Javascript :: js timer 
Javascript :: concatenation of loop data in variable using jquery 
Javascript :: insert property in json file with bash 
Javascript :: aria labelledby js 
Javascript :: get table schema with knex 
Javascript :: hide and show usingfunction components 
Javascript :: is javascript case sensitive 
Javascript :: show conditional header based on url in vue js 
Javascript :: express rate limit redis 
Javascript :: play store version of react native app 
Javascript :: append string in variable using jquery in each loop 
ADD CONTENT
Topic
Content
Source link
Name
6+5 =