Javascript Basics

260 flashcards · Programming Languages · by Mae000

  1. Java Script file extension?

    .js

  2. External Javascript

    javascript code written separately in order to be brought into a document <script src="javascript.js"> <script

  3. Function of console.log()

    To print something onto the console

  4. Variable Definition?

    variables are simply “storage containers” for data in your code.

  5. Ways to create variable in JS?

    var let const

  6. Difference between the 3 ways to write a variable

    let and const are newer than var and behave differently in some aspects.

  7. Recommended ways to write variables

    let and const

  8. How to assign a variable value

    Using the using the assignment operator =

  9. What does a string look like?

    'Hello!';

  10. Multi-line or single-line variables declarations?

    Multi-line cus readability

  11. True or False: You can only change a variable's value 20 times

    False. Infinite changes. Old Value is thrown away

  12. A variable has to be unique but can share values

    Bla Bla Black Sheep

  13. How many time should a variable be declared

    Once or else error

  14. Example of copying data from one variable into the other.

    message = hello;

  15. Name the limitations on naming variable

    The name must contain only letters, digits, or the symbols $ and _. The first character must not be a digit.

  16. In JS Case Matters

    Apple and apple are very different

  17. What names can't be used for variables?

    Reserved names

  18. Whats the function of the const?

    To create an unchanging value

  19. How to reassign values?

    declare without let

  20. Purpose of Upper-cased Constant

    Hard coded values like colors

  21. Rules for naming Variables

    Simple and Descriptive name Avoid Abbr.

  22. When should const not be upper case

    When its not hardcoded, when u desire change, when its value is decided in run time

  23. +

    Addition

  24. -

    Subtraction

  25. *

    Multiplication

  26. **

    Exponentiation

  27. /

    Division

  28. %

    Modulus (Remainder)

  29. ++

    Increment

  30. --

    Decrement

  31. Two numbers can be consider literals or variables or expressions

    # a

  32. What are operands?

    The numbers (in an arithmetic operation)

  33. The addition operator (+) adds numbers

    #

  34. The subtraction operator (-) subtracts numbers.

  35. The multiplication operator (*) multiplies numbers.

  36. The division operator (/) divides numbers.

  37. The modulus operator (%) returns the division remainder.

  38. The increment operator (++) increments numbers.

    increases by +1

  39. The decrement operator (--) decrements numbers.

    Decreases by -1

  40. The exponentiation operator (**) raises the first operand to the power of the second operand.

  41. Operator precedence describes the order in which operations are performed in an arithmetic expression.

    Pemdas

  42. JavaScript has only one type of number. Numbers can be written with or without decimals.

  43. Extra large or extra small numbers can be written with scientific (exponent) notation:

    let x = 123e5; // 12300000 let y = 123e-5; // 0.00123

  44. JavaScript numbers are always stored as double precision floating point numbers, following the international IEEE 754 standard.

  45. Integers (numbers without a period or exponent notation) are accurate up to 15 digits.

  46. Floating point arithmetic is not always 100% accurate:

  47. If you add two numbers, the result will be a number:

  48. -Numbers are added. Strings are concatenated.

  49. If you add a number and a string, the result will be a string concatenation:

  50. JavaScript will try to convert strings to numbers in all numeric operations:

  51. NaN is a JavaScript reserved word indicating that a number is not a legal number.

  52. But numbers can also be defined as objects with the keyword new:

    let x = 123; let y = new Number(123); The new keyword complicates the code and slows down execution speed.

  53. Comparing two JavaScript objects always returns false.

  54. Integers are floating-point numbers without a fraction. They can either be positive or negative.

    e.g. 10, 400, or -5.

  55. Floating point numbers (floats) have decimal points and decimal places.

    for example 12.5, and 56.7786543.

  56. Doubles are a specific type of floating point number that have greater precision than standard floating point numbers (meaning that they are accurate to a greater number of decimal places).

  57. Binary

    The lowest level language of computers; 0s and 1s.

  58. Octal

    Base 8, uses 0–7 in each column.

  59. Hexadecimal

    Base 16, uses 0–9 and then a–f in each column. You may have encountered these numbers before when setting colors in CSS.

  60. How many data types does Java script have for numbers and benefits?

    Numbers and it means all data types could be handled the same way

  61. JS second number type

    BigInt used for incredibly large Integers

  62. typeof operator

    returns the data type

  63. toFixed() method

    to round your number to a fixed number of decimal places,

  64. Convert String to Number

    Number (String)

  65. Position of the increment value

    At front (increment or decrement then returns). At back (need to rerun to give new value)

  66. Assignment operators

    operators that assign a value to a variable.

  67. =

    it assigns the variable on the left the value stated on the right

  68. +=

    Addition assignment: Adds the value on the right to the variable value on the left, then returns the new variable value (x += 4;)

  69. -=

    Subtraction assignment: Subtracts the value on the right from the variable value on the left, and returns the new variable value (x -= 3;)

  70. *=

    Multiplication assignment: Multiplies the variable value on the left by the value on the right, and returns the new variable value (x *= 3;)

  71. /=

    Division assignment: Divides the variable value on the left by the value on the right, and returns the new variable value (x /= 5;)

  72. comparison operators.

    run true/false tests, compare values

  73. ===

    Strict equality: Tests whether the left and right values are identical to one another (5 === 2 + 4)

  74. !==

    Strict-non-equality: Tests whether the left and right values are not identical to one another (5 !== 2 + 3)

  75. <

    Less than: Tests whether the left value is smaller than the right one. (10 < 6)

  76. >

    Greater than: Tests whether the left value is greater than the right one.(10 > 20)

  77. <=

    Less than or equal to: Tests whether the left value is smaller than or equal to the right one. (3 <= 2)

  78. >=

    Greater than or equal to: Tests whether the left value is greater than or equal to the right one. (5 >= 4)

  79. booleans data type

    true/false values

  80. operands

    is what operators are applied to (5 * 2)

  81. unary

    An operator is unary if it has a single operand

  82. the unary negation

    - reverses the sign of a number

  83. binary

    An operator is binary if it has two operands.

  84. String concatenation

    Combines string with the binary operator (+) "m" + "s" if one operand is string end result will be string

  85. Strings with other operators

    converts them to numbers

  86. The unary (+)

    converts string to numbers

  87. Unary position in pemdas

    Higher than binaries

  88. modify-and-assign

    += , etc.

  89. postfix form

    When the operator goes after the variable, counter++.

  90. prefix form

    when the operator goes before the variable: ++counter.

  91. When to use prefix?

    If we’d like to increase a value and immediately use the result of the operator

  92. When to use postfix?

    If we’d like to increment a value but use its previous value

  93. JS coding style, readability

    a style of “one line – one action”

  94. comma operator

    allows us to evaluate several expressions, dividing them with a comma ,. Each of them is evaluated but only the result of the last one is returned.

  95. comma operator precedence

    Very low, parentheses needed

  96. Whats a string?

    simply a piece of text surrounded by quotes

  97. Method

    a bit of functionality that is built into the language or into specific data types

  98. Quotes

    " '' " is good ' ' ' not good

  99. Escape characters

    (\) right before

  100. A template literal

    looks just like a normal string, but instead of using single or double quote marks (' or "), you use backtick characters (`): you can include variables in it, wrapped inside ${ }