Last active
August 29, 2015 14:21
-
-
Save ajitbohra/991752037a34e98194ba to your computer and use it in GitHub Desktop.
jQuery: String & number concatenation returning NaN
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//Scenario 1: String & Math calculation | |
"height :" + $(document).height() - $(window).height(); | |
//Result: NaN | |
//Scenario 2: String & Math calculation with parentheses | |
"height :" + ($(document).height() - $(window).height()); | |
//Result: Height : 1870 | |
//Scenario 3: String without match calculation | |
"Height:" + $(document).height(); | |
//Result: Height737 | |
//Scenario 4: Match Calculation & String | |
$(document).height() - $(window).height() + "Height"; | |
//Result: 1870Height | |
//Scenario 5: String & Match calculation (Converting math output to string) | |
"Height" + String($(document).height() - $(window).height()); | |
//Result: Height:1870 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment