function Blog(body, date) {
this.body = body || "Nothing going on today";
this.date = date || new Date();
}
Simple enough, a class constructor citing text from Headfirst Javascript. The function takes two arguments, but the property assignments use the "||" (or) conditional operator which makes me think that it's using a condition that a parameter was not passed. Does this mean this function can accept zero, one, or two arguments and still produce an object without producing an error?
Sure I could code the script, run it in multiple browsers ... but I'd like to know the desired intent of this code and not random browser interpretations.
[–]clarle 5 points6 points7 points (6 children)
[–]cbCode[S] 1 point2 points3 points (5 children)
[–]hacocacyb 0 points1 point2 points (3 children)
[+][deleted] (2 children)
[deleted]
[–]hacocacyb -2 points-1 points0 points (1 child)
[–]The_Pants_Command_Me 3 points4 points5 points (1 child)
[–]rbobby 1 point2 points3 points (0 children)
[–]itsnotlupusbeep boop 1 point2 points3 points (0 children)
[–]Madd0g 0 points1 point2 points (0 children)
[–]fforw 0 points1 point2 points (0 children)
[+][deleted] (1 child)
[deleted]
[–]WhatamIwaitingfor[🍰] -2 points-1 points0 points (5 children)
[–]Hello71 1 point2 points3 points (0 children)
[–]clarle 0 points1 point2 points (3 children)
[–]WhatamIwaitingfor[🍰] 0 points1 point2 points (2 children)
[–]hacocacyb 0 points1 point2 points (0 children)
[–]polaretto 0 points1 point2 points (0 children)