2. Lexical structure Flashcards
What is a lexical structure?
A set of rules that specifies how you write programs in that language
JavaScrip is a case sensitive language
Yes
A JS identifier must begin with what?
A letter,
an underscore,
a dollarsign
How do you write comments in JS?
// this is a comment
/* this is a multi
line
comment
*/
What is a literal?
A data value that appears directly in a program.
12 // The number twelve
1.2 // The number one point two
“hello world” // A string of text
‘Hi’ // Another string
true // A Boolean value
false // The other Boolean value
null // Absence of an object
What does ASCII mean?
American Standard Code for Information Interchange
Why do you use semicolons?
To mark an end of a statement.
How does JS interpret this code:
let a
a
=
3
console.log(a)
let a; a = 3; console.log(a);
JavaScript does not treat the second line break as a semicolon because it can continue parsing the longer statement a = 3;.
How does JS interpret this code:
let y = x + f
(a+b).toString()
let y = x + f (a+b).toString()
The parentheses on the second line of code can be interpreted as a function invocation of f from the first line.
For it to be a separate function, add a semicolon:
let y = x + f;