jsdatatypes_Quiz.md - brainchildservices/curriculum GitHub Wiki

Quiz

1. JavaScript Data Types?

  • A: Data types are a particular type of data item that determines what operations can be applied to them. Once a variable is assigned a data type it can be used for computations in the program. There are different types of data that we can use in a JavaScript program.

2. Different ways/types to Use Datatypes?

  • A: There are eight basic data types in JavaScript. They are:.
    • String : Represent Text Data.
    • Number : An integer or a floating-point number.
    • BigInt : An integer with an arbitrary precision.
    • Boolean: Any of two values, True or False.
    • Undefined: A datatype whose variable is not initialized.
    • null : denotes a null value.
    • Symbol : A datatype whose instances are unique and immutable.
    • Object : Key-value pairs of collection of data

3. What is the non-Primitive datatype?

  • A: Objects

4. How to name a javascript Database?

  • A: use camelCase everywhere, but keep using snake_case only for server-generated attributes. camelCase means always have to start with a lowercase letter, if there are more than one word, make the first letter of the Second word as UPPERCASE Letter.

5. Explain Javascript string?

  • A: Strings are used to store data that involves characters, like names or addresses. You can perform operations like string concatenation, in JavaScript. Strings are written with quotes. We can use single or double quotes. String is used to store text.

6. What do you mean by String Concatination?

  • A: Combining 2 strings into a single string is called string concatination.

7. Explain JavaScript Number?

  • A: Number type stands for both integers and floating points. Many mathematical operations are carried out using these numbers.

8. Someone declared a number like this const x1 = "34.00";, can you identify is it a correct format or not? why?

  • A: Its a wrong declaration, because in the given example the number is represented in quotes. which means its declared as a string.

### 9. Explain JavaScript BigInt?

  • A: In JavaScript, Number type can only represent numbers less than (253 - 1) and more than -(253 - 1). However, if you need to use a larger number than that, you can use the BigInt data type.

10. Explain Javascript Boolean?

  • This data type represents logical entities. Boolean represents one of two values: true or false. This type is usually used to check if something is correct or incorrect.

11. What will be the default value of a type if value is not assigned?

  • A: Undefined

12. Is it possible to assign a variable value undefined?

  • A: yes it is possible to explicitly assign a variable value undefined. For example,

    let name = undefined;
    document.write("Name is " + name); //age is a undefined