Vous êtes sur la page 1sur 2

1. How to declare a variable?

(5pts)
Declaring a variable in Javascript is similar to declaring a variable in most programming
languages. The purpose of a variable is to store information (values, expressions) which can be
used later. It is declared by using Var.
2. What is variable scope? (3pts)
JavaScript has two scopes: global and local. A variable that is declared outside a function
definition is a global variable, and its value is accessible and modifiable throughout your
program. A variable that is declared inside a function definition is local.
3. What are the rules for variables name (2pts)
A variable name cannot start with a numeral. For instance, 3x or 2goats or 76trombones would
all be illegal variable names.
4. What does the toFixed() method do?? (2 pts)
The toFixed() method converts a number into a string, keeping a specified number of decimals.
5. What is an empty string?? (5pts)
The empty string is the special case where the sequence has length zero, so there are no symbols
in the string. There is only one empty string, because two strings are only different if they have
different lengths or a different sequence of symbols.
6. What are escape sequences? (3 pts)
An escape sequence is a sequence of characters that does not represent itself when used inside a
character or string literal, but is translated into another character or a sequence of characters that
may be difficult or impossible to represent directly.
7. What are some of the ways you can convert a
string to a number? (5 pts)
There are many ways of doing so, starting
with parseFloat() and parseInt(). These are top-level functions, which is to
say they are not associated with any object and can be called directly. The first
function always returns a floating-point number (aka, a decimal), and the latter,
an integer. Both functions take the value to be converted as its first argument. The
parseInt() function takes the radix as the second. The radix is the numbers base,
as in base-8 (aka, octal), base-10 (decimal), and base-16 (hexadecimal).

8. What is (5 pts)

Boolean
Boolean data type is a data type with only two possible values: true or false.
NaN
In computing, NaN, standing for not a number, is a numeric data type value representing an
undefined or unrepresentable value, especially in floating-point calculations.
Scope
In JavaScript, scope is the set of variables, objects, and functions you have access to.
String
A JavaScript string stores a series of characters like "John Doe".
A string can be any text inside double or single quotes.
Null
The value null is a JavaScript literal representing null or an "empty" value, i.e. no object value is
present. It is one of JavaScript's primitive values.

Vous aimerez peut-être aussi