2. Lexical structure Flashcards

1
Q

What is a lexical structure?

A

A set of rules that specifies how you write programs in that language

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

JavaScrip is a case sensitive language

A

Yes

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

A JS identifier must begin with what?

A

A letter,
an underscore,
a dollarsign

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

How do you write comments in JS?

A

// this is a comment

/* this is a multi
line
comment
*/

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

What is a literal?

A

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

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

What does ASCII mean?

A

American Standard Code for Information Interchange

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

Why do you use semicolons?

A

To mark an end of a statement.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

How does JS interpret this code:
let a
a
=
3
console.log(a)

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 well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

How does JS interpret this code:
let y = x + f
(a+b).toString()

A

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;

How well did you know this?
1
Not at all
2
3
4
5
Perfectly