Questions
Of the following identifiers, which are valid, which are not, and why?
$someVariable _someVariable 1Variable some_variable somèvariable function .someVariable some*variable
Convert the following identifiers using the conventions outlined in the first section of the chapter:
var some_month; function theMonth // function to return current month current-month // a constant var summer_month; // an array of summer months MyLibrary-afunction // a function from a JavaScript package
Is the following string literal valid? If not, how would you fix it?
var someString = âWho once said, âOnly two things are infinite, the universe and human stupidity, and Iâm not sure about the former.ââ
Given a number, 432.54, what JavaScript returns the integer component of the number, and then finds the hexadecimal and octal conversion?
You create a JavaScript function in a library that can be used by other applications. A parameter,
someMonth
, is passed to the function. How would you determine whether itâs null or undefined?
Answers are provided in the appendix.
Get Learning JavaScript now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.