diff options
author | Adam Bard <github@adambard.com> | 2015-10-18 11:54:59 +0800 |
---|---|---|
committer | Adam Bard <github@adambard.com> | 2015-10-18 11:54:59 +0800 |
commit | e34123e5df04438eda1a14e2448c4cc4f6555429 (patch) | |
tree | 1a9583c3828b1ca3a24b3e70e76a010f3b42a1e9 /javascript.html.markdown | |
parent | 324c707c086b1a35583b33aae0516e332852f2a7 (diff) | |
parent | 53366ebdbeecb502131c2768979e4b6ed9d59d9f (diff) |
Merge pull request #1608 from venegu/master
[javascript/en] Adding modulo division
Diffstat (limited to 'javascript.html.markdown')
-rw-r--r-- | javascript.html.markdown | 13 |
1 files changed, 9 insertions, 4 deletions
diff --git a/javascript.html.markdown b/javascript.html.markdown index 34ba9b47..937354eb 100644 --- a/javascript.html.markdown +++ b/javascript.html.markdown @@ -54,6 +54,11 @@ doStuff() // Including uneven division. 5 / 2; // = 2.5 +// And modulo division. +10 % 2; // = 0 +30 % 4; // = 2 +18.5 % 7; // = 4.5 + // Bitwise operations also work; when you perform a bitwise operation your float // is converted to a signed int *up to* 32 bits. 1 << 2; // = 4 @@ -104,7 +109,7 @@ null == undefined; // = true // ...unless you use === "5" === 5; // = false -null === undefined; // = false +null === undefined; // = false // ...which can result in some weird behaviour... 13 + !0; // 14 @@ -220,15 +225,15 @@ for (var i = 0; i < 5; i++){ //The For/In statement loops iterates over every property across the entire prototype chain var description = ""; -var person = {fname:"Paul", lname:"Ken", age:18}; +var person = {fname:"Paul", lname:"Ken", age:18}; for (var x in person){ description += person[x] + " "; } -//If only want to consider properties attached to the object itself, +//If only want to consider properties attached to the object itself, //and not its prototypes use hasOwnProperty() check var description = ""; -var person = {fname:"Paul", lname:"Ken", age:18}; +var person = {fname:"Paul", lname:"Ken", age:18}; for (var x in person){ if (person.hasOwnProperty(x)){ description += person[x] + " "; |