🎧 New: AI-Generated Podcasts Turn your study notes into engaging audio conversations. Learn more

JavaScript Perusteet
5 Questions
0 Views

JavaScript Perusteet

Created by
@FashionableLilac

Podcast Beta

Play an AI-generated podcast conversation about this lesson

Questions and Answers

JavaScriptissa käytetään näitä kolmea avainsanaa: let, const ja ______ julistamaan muuttujia.

var

JavaScriptissa on seitsemän tietotyyppiä, joista yksi on ______ numeroarvot, esim. 42

Number

Merkkijonot ovat yksi JavaScriptin seitsemästä tietotyypistä, ja ne esitetään aina ______ sisällä.

lainausmerkein

Vertailuoperaattoreita käytetään JavaScriptissa vertailemaan arvoja, ja niitä ovat esimerkiksi == ja ______.

<p>!=</p> Signup and view all the answers

JavaScriptissa on useita matemaattisia operaattoreita, joista yksi on ______ jakolasku.

<p>/</p> Signup and view all the answers

Study Notes

JavaScript Syntax

Variables and Data Types

  • Declaring variables: let, const, and var keywords are used to declare variables
    • let and const are block-scoped, while var is function-scoped
    • const declares a constant variable, which cannot be reassigned
  • Data types: JavaScript has seven data types:
    1. Number: numeric values, e.g. 42
    2. String: character sequences, e.g. "hello"
    3. Boolean: true or false values
    4. Null: represents the absence of any object value
    5. Undefined: represents an uninitialized variable
    6. Object: collections of key-value pairs, e.g. { name: "John", age: 30 }
    7. Symbol: unique identifiers, used to create unique property names

Operators

  • Arithmetic operators:
    • + addition
    • - subtraction
    • * multiplication
    • / division
    • % modulus
    • ** exponentiation
  • Comparison operators:
    • == equality
    • != inequality
    • === strict equality
    • !== strict inequality
    • &gt; greater than
    • &lt; less than
    • &gt;= greater than or equal to
    • &lt;= less than or equal to
  • Logical operators:
    • &amp;&amp; logical and
    • || logical or
    • ! logical not

Control Flow

  • Conditional statements:
    • if statement: executes a block of code if a condition is true
    • else statement: executes a block of code if a condition is false
    • switch statement: executes a block of code based on a value
  • Loops:
    • for loop: executes a block of code repeatedly for a specified number of iterations
    • while loop: executes a block of code repeatedly while a condition is true
    • do-while loop: executes a block of code repeatedly while a condition is true

Functions

  • Function declaration: function keyword is used to declare a function
    • function name(parameters) { code }
  • Function call: a function is called by using the function name followed by parentheses containing arguments
    • name(arg1, arg2, ...)

Arrays and Objects

  • Array: a collection of values, e.g. [1, 2, 3, 4, 5]
    • created using the [] syntax
    • accessed using the index number, e.g. arr[0]
  • Object: a collection of key-value pairs, e.g. { name: "John", age: 30 }
    • created using the {} syntax
    • accessed using the property name, e.g. obj.name

JavaScriptin syntaksi

Muuttujat ja tietotyyppi

  • Muuttujien määrittely: let, const ja var avainsanat käytetään muuttujien määrittelyyn
    • let ja const ovat lohkoalueellisia, kun taas var on funktioalueellinen
    • const määrittää vakion muuttujan, jota ei voi uudelleenmäärittää
  • Tietotyypit: JavaScriptissa on seitsemän tietotyyppiä:
    • Luku: numeeriset arvot, esim. 42
    • Merkkijono: merkkijonot, esim. "hello"
    • Totuusarvo: tosi tai epätosi arvot
    • Null: edustaa minkään objektin arvon puuttumista
    • Määrittämätön: edustaa alustamatta jäänyttä muuttujaa
    • Objekti: avain-arvo -parien kokoelmia, esim. { nimi: "Jouni", ikä: 30 }
    • Symboli: uniikit tunnisteet, käytetään uniikkien ominaisuuksien luomiseen

Operaattorit

  • Aritymetiset operaattorit:
    • + yhteenlasku
    • - vähennyslasku
    • * kertolasku
    • / jakolasku
    • % jakojäännös
    • ** eksponentti
  • Vertailuoperaattorit:
    • == yhtäsuuruus
    • != epäyhtäsuuruus
    • === tiukka yhtäsuuruus
    • !== tiukka epäyhtäsuuruus
    • &gt; suurempi kuin
    • &gt;= suurempi tai yhtäsuuri kuin
    • &lt; pienempi kuin

Studying That Suits You

Use AI to generate personalized quizzes and flashcards to suit your learning preferences.

Quiz Team

Description

Tämä kysely kattaa JavaScriptin perusteet, mukaan lukien muuttujien julistamisen, tietotyyppien ja niiden ominaisuuksien.

More Quizzes Like This

JavaScript Syntax: .Script Elements
18 questions
JavaScript Syntax and Type Conversion Quiz
12 questions
JavaScript Fundamentals
10 questions
JavaScript Rest Parameter Syntax
10 questions
Use Quizgecko on...
Browser
Browser