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
parseInt("a12") // return NaN | |
parseInt("12", 1) // return NaN | |
parseInt("12", 50) // return NaN | |
parseInt("12") // return 12 | |
parseInt("12", 10) // return 12 | |
parseInt("12", 8) // return 10 | |
parseInt("12", 16) // return 18 | |
parseInt("01") // return 1 | |
parseInt("08") // return 0 | |
parseInt("08", 10) // return 8 |
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
var str = new String("foo"); // String Object | |
typeof str; // return "Object" | |
typeof str.valueOf(); // return "String" | |
var str = String("foo"); // Primitive String | |
typeof str; // return "String" | |
var str = "foo"; // Primitive String (literal) | |
typeof str; // return "String" |
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
var str = "foo"; // Literal String | |
str.replace('f', 'o'); // Modified the string | |
str; // return "foo" not "ooo" | |
// similar strings are equal | |
var s = "abc"; | |
var d = "abc"; | |
d == d; // return true | |
// String methods like charAt, indexOf |
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
var str = new String("foo"); // String Object | |
str.length; // return 3 | |
var str = "foo"; // String Literal | |
str.length; // return 3 |
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
class Animal | |
attr_accessor :name | |
def initialize(name) | |
@name = name | |
end | |
end | |
class Cat < Animal | |
def talk | |
@name |
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
var foo = 12; // return 12 | |
var foo = NaN; | |
foo; // return NaN | |
typeof foo; // return "number" | |
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
var foo = Number("4l"); | |
num; // return 41 | |
var foo = Number("4la"); | |
num; // return NaN | |
//also + prefix operator convert a string t a number | |
var foo = +"12"; | |
foo; // return 12 |
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
var foo = Number("4l"); | |
num; // return 41 | |
var foo = Number("4la"); | |
num; // return NaN | |
//also + prefix operator convert a string t a number | |
var foo = +"12"; | |
foo; // return 12 |
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
var foo = NaN; // NaN is false value | |
Boolean(foo); // return false | |
!!NaN; // return false | |
!NaN; // return true | |
var foo = "i love javascript"; // string is true value but empty string "" is false value | |
Boolean(foo); // return true | |
!!foo; // return true | |
!foo; // convert the value to boolean and negates it // return false |
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
var foo = null; | |
typeof foo; // return "object" |
OlderNewer